<commit_before>'use strict';

const MODULE_ID = 'anonToggle';

export default class AnonToggle {
	constructor(core, settings) {
		this._core = core;
		this._settings = settings;
		this._initialiseSettings();
		this._onClickShouldSetToAnon = false;
		this._styleElement = null;
		this._toggleElement = null;
		this._avatarElement = null;
		this._usernameElement = null;
		this._addCSS();
		this._createToggleElement();
		this._core.on('focus', this._onFocus, this);
		this._core.on('dom.added.chatHeader', this._onAddedChatHeader, this);
	}

	static get id() {
		return MODULE_ID;
	}

	_initialiseSettings() {
	}

	_addCSS() {
		this._styleElement = document.createElement('style');
		this._styleElement.id = 'akun-x-anon-toggle-css';
		this._styleElement.textContent = `.akun-x-anon-toggle {
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

.akun-x-anon-toggle .avatar{
	margin-right: 4px;
	display: inline;
	-webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    -ms-border-radius: 2em;
	border-radius: 2em;
	position: relative;
	top: -1px;
}`;
		document.querySelector('head').appendChild(this._styleElement);
	}

	_createToggleElement() {
		const toggleElement = document.createElement('div');
		toggleElement.classList.add('akun-x-anon-toggle', 'noselect', 'btn', 'dim-font-color', 'hover-font-color');
		toggleElement.addEventListener('click', this._toggleClickCallback.bind(this));
		const avatarElement = document.createElement('img');
		avatarElement.classList.add('avatar');
		const usernameElement = document.createElement('span');
		toggleElement.appendChild(avatarElement);
		toggleElement.appendChild(usernameElement);
		this._toggleElement = toggleElement;
		this._avatarElement = avatarElement;
		this._usernameElement = usernameElement;
	}

	_toggleClickCallback(e) {
		const currentUser = AnonToggle._getCurrentUser();
		currentUser['profile']['asAnon'] = this._onClickShouldSetToAnon;
		this._updateProfileSettings(currentUser['profile']);
		this._updateToggleElement(currentUser);
	}

	_onFocus() {<commit_msg>Refactored for better clarity<commit_after>'use strict';

const MODULE_ID = 'anonToggle';

const CSS = `
.akun-x-anon-toggle {
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

.akun-x-anon-toggle .avatar{
	margin-right: 4px;
	display: inline;
	-webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    -ms-border-radius: 2em;
	border-radius: 2em;
	position: relative;
	top: -1px;
}`;

export default class AnonToggle {
	constructor(core, settings) {
		this._core = core;
		this._settings = settings;
		this._initialiseSettings();
		this._onClickShouldSetToAnon = false;
		this._styleElement = null;
		this._toggleElement = null;
		this._avatarElement = null;
		this._usernameElement = null;
		this._addCSS();
		this._createToggleElement();
		this._core.on('focus', this._onFocus, this);
		this._core.on('dom.added.chatHeader', this._onAddedChatHeader, this);
	}

	static get id() {
		return MODULE_ID;
	}

	_initialiseSettings() {
	}

	_addCSS() {
		this._styleElement = document.createElement('style');
		this._styleElement.id = 'akun-x-anon-toggle-css';
		this._styleElement.textContent = CSS;
		document.querySelector('head').appendChild(this._styleElement);
	}

	_createToggleElement() {
		const toggleElement = document.createElement('div');
		toggleElement.classList.add('akun-x-anon-toggle', 'noselect', 'btn', 'dim-font-color', 'hover-font-color');
		toggleElement.addEventListener('click', this._toggleClickCallback.bind(this));
		const avatarElement = document.createElement('img');
		avatarElement.classList.add('avatar');
		const usernameElement = document.createElement('span');
		toggleElement.appendChild(avatarElement);
		toggleElement.appendChild(usernameElement);
		this._toggleElement = toggleElement;
		this._avatarElement = avatarElement;
		this._usernameElement = usernameElement;
	}

	_toggleClickCallback(e) {
		const currentUser = AnonToggle._getCurrentUser();
		currentUser['profile']['asAnon'] = this._onClickShouldSetToAnon;
		this._updateProfileSettings(currentUser['profile']);
		this._updateToggleElement(currentUser);
	}

	_onFocus() {
{'fraction_non_alphanumeric': 0.14302244850728998, 'fraction_numerical': 0.00277713492247165, 'mean_word_length': 5.121813031161473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6783220', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1407, 'n_words': 232}