${s.meta.description}
`; this._section.innerHTML = innerHTML; this.update(s); } update = (s: Section) => { for (let name of s.order) { let setting: Setting = s.settings[name]; if (name in this._settings) { this._settings[name].update(setting); } else { if (setting.deprecated) continue; switch (setting.type) { case "text": setting = new DOMText(setting, this._sectionName, name); break; case "password": setting = new DOMPassword(setting, this._sectionName, name); break; case "email": setting = new DOMEmail(setting, this._sectionName, name); break; case "number": setting = new DOMNumber(setting, this._sectionName, name); break; case "bool": setting = new DOMBool(setting as SBool, this._sectionName, name); break; case "select": setting = new DOMSelect(setting as SSelect, this._sectionName, name); break; case "note": setting = new DOMNote(setting as SNote, this._sectionName); break; case "list": setting = new DOMList(setting as SList, this._sectionName, name); break; } if (setting.type != "note") { this.values[name] = ""+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}-${name}`, (event: CustomEvent) => { // const oldValue = this.values[name]; this.values[name] = event.detail; document.dispatchEvent(new CustomEvent("settings-section-changed")); }); } this._section.appendChild(setting.asElement()); this._settings[name] = 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 { order: string[]; sections: { [sectionName: string]: 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