thedesk/app/js/ui/theme.js

33 lines
839 B
JavaScript
Raw Normal View History

2018-01-28 23:22:43 +11:00
//テーマ適用
function themes(theme) {
if (!theme) {
var theme = localStorage.getItem("theme");
2019-05-19 17:39:30 +10:00
if (!theme) {
var theme = "black";
localStorage.setItem("theme", "black");
2018-03-13 04:41:38 +11:00
}
2018-01-28 23:22:43 +11:00
}
2019-08-11 03:52:32 +10:00
var el = document.getElementsByTagName("html")[0]
el.classList.remove('indigotheme');
el.classList.remove('greentheme');
el.classList.remove('browntheme');
el.classList.remove('blacktheme');
el.classList.remove('bluetheme');
el.classList.remove('customtheme');
el.classList.add(theme + "theme");
2018-07-05 11:26:07 +10:00
var font = localStorage.getItem("font");
2019-05-19 17:39:30 +10:00
if (font) {
2019-08-11 03:52:32 +10:00
el.style.fontFamily = font;
2019-05-19 17:39:30 +10:00
} else {
2019-08-11 03:52:32 +10:00
el.style.fontFamily = "";
2018-07-05 11:26:07 +10:00
}
2019-05-19 17:39:30 +10:00
if (theme == "custom") {
if (localStorage.getItem("customtheme-id")) {
2019-06-15 03:23:41 +10:00
postMessage(["themeCSSRequest", localStorage.getItem("customtheme-id")], "*")
2019-03-08 05:19:26 +11:00
}
}
2019-08-11 03:52:32 +10:00
el.style.backgroundColor = "var(--bg)";
2018-01-28 23:22:43 +11:00
}
2019-08-11 03:52:32 +10:00
themes();