optionsHtmlFromArray to optionsFromArray
This commit is contained in:
parent
f5c125d61c
commit
0e9c8f290c
14
edit/edit.js
14
edit/edit.js
|
@ -260,24 +260,26 @@ function initCodeMirror() {
|
|||
};
|
||||
|
||||
// initialize global editor controls
|
||||
function optionsHtmlFromArray(options) {
|
||||
return options.map(opt => '<option>' + opt + '</option>').join('');
|
||||
function optionsFromArray(parent, options) {
|
||||
console.log(parent, options);
|
||||
options.map(opt => $element({tag: 'option', textContent: opt}))
|
||||
.forEach(opt => parent.appendChild(opt));
|
||||
}
|
||||
const themeControl = document.getElementById('editor.theme');
|
||||
const themeList = localStorage.codeMirrorThemes;
|
||||
if (themeList) {
|
||||
themeControl.innerHTML = optionsHtmlFromArray(themeList.split(/\s+/));
|
||||
optionsFromArray(themeControl, themeList.split(/\s+/));
|
||||
} else {
|
||||
// Chrome is starting up and shows our edit.html, but the background page isn't loaded yet
|
||||
const theme = prefs.get('editor.theme');
|
||||
themeControl.innerHTML = optionsHtmlFromArray([theme === 'default' ? t('defaultTheme') : theme]);
|
||||
optionsFromArray(themeControl, [theme === 'default' ? t('defaultTheme') : theme]);
|
||||
getCodeMirrorThemes().then(() => {
|
||||
const themes = (localStorage.codeMirrorThemes || '').split(/\s+/);
|
||||
themeControl.innerHTML = optionsHtmlFromArray(themes);
|
||||
optionsFromArray(themeControl, themes);
|
||||
themeControl.selectedIndex = Math.max(0, themes.indexOf(theme));
|
||||
});
|
||||
}
|
||||
document.getElementById('editor.keyMap').innerHTML = optionsHtmlFromArray(Object.keys(CM.keyMap).sort());
|
||||
optionsFromArray($('#editor.keyMap'), Object.keys(CM.keyMap).sort());
|
||||
document.getElementById('options').addEventListener('change', acmeEventListener, false);
|
||||
setupLivePrefs();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user