Don't change localstorage when url defines so

This commit is contained in:
Jeremy Zhang 2017-10-04 06:04:27 +00:00
parent 370d4c6985
commit 65381b9739

View File

@ -226,7 +226,7 @@
} else { } else {
theme = localstore_theme; theme = localstore_theme;
} }
changeTheme(theme); changeTheme(theme, true, false);
$("#theme-selector option").removeAttr('selected'); $("#theme-selector option").removeAttr('selected');
$("#theme-selector option[value=" + theme + "]").attr('selected', 'selected'); $("#theme-selector option[value=" + theme + "]").attr('selected', 'selected');
$('select').material_select(); $('select').material_select();
@ -252,11 +252,13 @@
} }
}); });
function changeTheme(theme=null, keep_custom_css=true) { function changeTheme(theme=null, keep_custom_css=true, modifyLocalStore=true) {
if (theme == "") { if (theme == "") {
$("#css-theme").attr("href", ""); $("#css-theme").attr("href", "");
$("#user-defined-css").text(user_def_css); $("#user-defined-css").text(user_def_css);
if (modifyLocalStore) {
localStorage.removeItem("theme"); localStorage.removeItem("theme");
}
} else if ($.inArray(theme, theme_options) != -1 || theme == null) { } else if ($.inArray(theme, theme_options) != -1 || theme == null) {
if (!keep_custom_css) { if (!keep_custom_css) {
$("#user-defined-css").text(""); $("#user-defined-css").text("");
@ -265,10 +267,12 @@
} }
if (theme) { if (theme) {
$("#css-theme").attr("href", "/static/themes/" + theme + "/css/style.css"); $("#css-theme").attr("href", "/static/themes/" + theme + "/css/style.css");
if (modifyLocalStore) {
localStorage.setItem("theme", theme); localStorage.setItem("theme", theme);
} }
} }
} }
}
/* https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript */ /* https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript */
function getParameterByName(name, url) { function getParameterByName(name, url) {