robust theme selector

This commit is contained in:
Koen Lageveen 2017-07-29 11:41:12 +02:00
parent 795afa896f
commit 0a7b35ef8a
1 changed files with 5 additions and 1 deletions

View File

@ -16,7 +16,11 @@ function applyColors() {
// CodeMirror theme selector
var input = document.getElementById("select-theme");
function selectTheme() {
var theme = input.options[input.selectedIndex].innerHTML;
if (input.selectedIndex > -1) {
var theme = input.options[input.selectedIndex].innerHTML;
} else {
var theme = "monokai";
}
editor.setOption("theme", theme);
document.cookie = "theme=" + theme + ";max-age=172800";
applyColors();