2022-03-04 05:47:18 -05:00
|
|
|
/* @license http://creativecommons.org/publicdomain/zero/1.0/legalcode CC0-1.0 */
|
|
|
|
|
|
|
|
// This component is dedicated to the public domain. It uses the CC0
|
|
|
|
// as a formal dedication to the public domain and in circumstances where
|
|
|
|
// a public domain is not usable.
|
|
|
|
|
|
|
|
var oldTheme = "ubergine";
|
2022-03-11 07:13:09 -05:00
|
|
|
var change = false;
|
2022-03-04 05:47:18 -05:00
|
|
|
|
|
|
|
function swapStyleSheet(theme) {
|
|
|
|
// https://stackoverflow.com/questions/14292997/changing-style-sheet-javascript
|
|
|
|
document.getElementById("pagestyle").setAttribute("href", "/i2psnark/.resources/themes/" + theme + "/snark.css");
|
|
|
|
}
|
|
|
|
|
|
|
|
function initThemeSwitcher() {
|
|
|
|
var theme = document.getElementById("theme");
|
|
|
|
if (theme == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
oldtheme = theme.value;
|
|
|
|
theme.onclick = function() {
|
2022-03-11 07:13:09 -05:00
|
|
|
if (change) {
|
|
|
|
swapStyleSheet(theme.value);
|
|
|
|
} else {
|
|
|
|
// skip the first click to avoid the flash
|
|
|
|
change = true;
|
|
|
|
}
|
2022-03-04 05:47:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
initThemeSwitcher();
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
/* @license-end */
|