33 lines
893 B
JavaScript
33 lines
893 B
JavaScript
function updateTheme(a){
|
|
console.log("a");
|
|
// delTheme();
|
|
// if(currentTheme=="today"){
|
|
// link.href = "styles/today/main.css";
|
|
// }else if(themeName=="2000"){
|
|
// setTheme(themeName);
|
|
}
|
|
|
|
function delTheme(){
|
|
let themeNode = document.getElementById("theme");
|
|
themeNode.parentNode.removeChild(themeNode);
|
|
}
|
|
|
|
function setTheme(themeName){
|
|
|
|
let head = document.getElementsByTagName("HEAD")[0];
|
|
let link = document.createElement("link");
|
|
|
|
// set the attributes for link element
|
|
link.rel = "stylesheet";
|
|
link.type = "text/css";
|
|
link.id = "theme";
|
|
if(themeName=="today"){
|
|
link.href = "styles/today/main.css";
|
|
}else if(themeName=="2000"){
|
|
link.href = "styles/2000/main.css";
|
|
}else throw new Error("invalid theme : "+themeName);
|
|
head.appendChild(link);
|
|
}
|
|
|
|
var currentTheme = "today";
|
|
setTheme(currentTheme); |