${s.meta.description}
`; this._section.innerHTML = innerHTML; this.update(s); } update = (s: Section) => { for (let setting of s.settings) { if (setting.setting in this._settings) { this._settings[setting.setting].update(setting); } else { if (setting.deprecated) continue; switch (setting.type) { case TextType: setting = new DOMText(setting, this._sectionName, setting.setting); break; case PasswordType: setting = new DOMPassword(setting, this._sectionName, setting.setting); break; case EmailType: setting = new DOMEmail(setting, this._sectionName, setting.setting); break; case NumberType: setting = new DOMNumber(setting, this._sectionName, setting.setting); break; case BoolType: setting = new DOMBool(setting as SBool, this._sectionName, setting.setting); break; case SelectType: setting = new DOMSelect(setting as SSelect, this._sectionName, setting.setting); break; case NoteType: setting = new DOMNote(setting as SNote, this._sectionName); break; case ListType: setting = new DOMList(setting as SList, this._sectionName, setting.setting); break; } if (setting.type != "note") { this.values[setting.setting] = ""+setting.value; // settings-section-name: Implies the setting changed or was shown/hidden. // settings-set-section-name: Implies the setting changed. document.addEventListener(`settings-set-${this._sectionName}-${setting.setting}`, (event: CustomEvent) => { // const oldValue = this.values[name]; this.values[setting.setting] = event.detail; document.dispatchEvent(new CustomEvent("settings-section-changed")); }); } this._section.appendChild(setting.asElement()); this._settings[setting.setting] = setting; } } } get visible(): boolean { return !this._section.classList.contains("unfocused"); } set visible(s: boolean) { if (s) { this._section.classList.remove("unfocused"); } else { this._section.classList.add("unfocused"); } } asElement = (): HTMLDivElement => { return this._section; } } interface Settings { sections: Section[]; } export class settingsList { private _saveButton = document.getElementById("settings-save") as HTMLSpanElement; private _saveNoRestart = document.getElementById("settings-apply-no-restart") as HTMLSpanElement; private _saveRestart = document.getElementById("settings-apply-restart") as HTMLSpanElement; private _loader = document.getElementById("settings-loader") as HTMLDivElement; private _panel = document.getElementById("settings-panel") as HTMLDivElement; private _sidebar = document.getElementById("settings-sidebar") as HTMLDivElement; private _visibleSection: string; private _sections: { [name: string]: sectionPanel } private _buttons: { [name: string]: HTMLSpanElement } private _needsRestart: boolean = false; private _messageEditor = new MessageEditor(); private _settings: Settings; private _advanced: boolean = false; private _searchbox: HTMLInputElement = document.getElementById("settings-search") as HTMLInputElement; private _clearSearchboxButtons: Array