Files
static-manga-engine/js/theming.js
T
Hell13Cat c2a92b5f93 eng0.2.0
2022-04-13 23:24:25 +03:00

34 lines
999 B
JavaScript

function addstylesheet(name_short) {
var head = document.head;
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
name_style = "css/color-"+name_short+".css"
link.href = name_style;
link.id = "currentstylesheet";
head.appendChild(link);
}
function startstylepage() {
var cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)theme\s*\=\s*([^;]*).*$)|^.*$/, "$1");
if(cookieValue == "") {
addstylesheet("dark");
} else {
addstylesheet(cookieValue);
}
}
function swap_theme(num) {
if(num == 1) {
document.cookie = "theme=dark; max-age=2592000; secure";
document.getElementById('currentstylesheet').remove();
addstylesheet("dark");
} else if (num == 2) {
document.cookie = "theme=light; max-age=2592000; secure";
document.getElementById('currentstylesheet').remove();
addstylesheet("light");
} else {
// Ignore
}
}