MCPcopy Create free account
hub / github.com/TechSpiritSS/Terminal-Portfolio / setTheme

Function setTheme

scripts/themeSetter.js:4–27  ·  view source on GitHub ↗
(theme)

Source from the content-addressed store, hash-verified

2
3
4function setTheme(theme) {
5 const chosenTheme = "./themes/" + theme + ".css";
6 document.getElementById("switcher-id").href = chosenTheme;
7
8 localStorage.setItem("style", theme);
9 if (theme === "default") {
10 document.documentElement.setAttribute("data-theme", "default");
11 } else if (theme === "nature") {
12 document.documentElement.setAttribute("data-theme", "nature");
13 } else if (theme === "metalic") {
14 document.documentElement.setAttribute("data-theme", "metalic");
15 } else if (theme === "matrix") {
16 document.documentElement.setAttribute("data-theme", "matrix");
17 } else if (theme === "sky") {
18 document.documentElement.setAttribute("data-theme", "sky");
19 } else if (theme === "dracula") {
20 document.documentElement.setAttribute("data-theme", "dracula");
21 } else if (theme === "vibrant") {
22 document.documentElement.setAttribute("data-theme", "vibrant");
23 } else if (theme === "galaxy") {
24 document.documentElement.setAttribute("data-theme", "galaxy");
25 }
26 localStorage.setItem("style", theme);
27}
28
29export {
30 //function exported

Callers 1

script.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected