Files
static-manga-engine/js/theming.js
T
Hell13Cat 517217e8e2 eng0.3.0
2022-04-16 15:20:38 +03:00

38 lines
1.2 KiB
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=black; max-age=2592000; secure";
document.getElementById('currentstylesheet').remove();
addstylesheet("black");
} else if (num == 2) {
document.cookie = "theme=light; max-age=2592000; secure";
document.getElementById('currentstylesheet').remove();
addstylesheet("light");
} else if (num == 3) {
document.cookie = "theme=dark; max-age=2592000; secure";
document.getElementById('currentstylesheet').remove();
addstylesheet("dark");
} else {
// Ignore
}
}