mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Store user theme choice in localstorage
This commit is contained in:
parent
735bcbea75
commit
16232cf434
@ -4,6 +4,7 @@
|
|||||||
/* global guild_id */
|
/* global guild_id */
|
||||||
/* global bot_client_id */
|
/* global bot_client_id */
|
||||||
/* global moment */
|
/* global moment */
|
||||||
|
/* global localStorage */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const theme_options = ["DiscordDark", "BetterTitan"]; // All the avaliable theming names
|
const theme_options = ["DiscordDark", "BetterTitan"]; // All the avaliable theming names
|
||||||
@ -128,10 +129,18 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
var themeparam = getParameterByName('theme');
|
var themeparam = getParameterByName('theme');
|
||||||
if (themeparam && $.inArray(themeparam, theme_options) != -1) {
|
var localstore_theme = localStorage.getItem("theme");
|
||||||
changeTheme(themeparam);
|
if ((themeparam && $.inArray(themeparam, theme_options) != -1) || (localstore_theme)) {
|
||||||
|
var theme;
|
||||||
|
if (themeparam) {
|
||||||
|
theme = themeparam;
|
||||||
|
} else {
|
||||||
|
theme = localstore_theme;
|
||||||
|
}
|
||||||
|
changeTheme(theme);
|
||||||
$("#theme-selector option").removeAttr('selected');
|
$("#theme-selector option").removeAttr('selected');
|
||||||
$("#theme-selector option[value=" + themeparam + "]").attr('selected', 'selected');
|
$("#theme-selector option[value=" + theme + "]").attr('selected', 'selected');
|
||||||
|
$('select').material_select();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -139,9 +148,11 @@
|
|||||||
if (theme == "") {
|
if (theme == "") {
|
||||||
$("#css-theme").attr("href", "");
|
$("#css-theme").attr("href", "");
|
||||||
disable_userdef_css(false);
|
disable_userdef_css(false);
|
||||||
|
localStorage.removeItem("theme");
|
||||||
} else if ($.inArray(theme, theme_options) != -1) {
|
} else if ($.inArray(theme, theme_options) != -1) {
|
||||||
disable_userdef_css(true);
|
disable_userdef_css(true);
|
||||||
$("#css-theme").attr("href", "/static/themes/" + theme + "/css/style.css");
|
$("#css-theme").attr("href", "/static/themes/" + theme + "/css/style.css");
|
||||||
|
localStorage.setItem("theme", theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user