MCPcopy Create free account
hub / github.com/ShafiqSadat/HamsterKeyGenWeb / toggleTheme

Function toggleTheme

script.js:1–16  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1function toggleTheme() {
2 const html = document.documentElement;
3 const themeIcon = document.getElementById('themeIcon');
4
5 if (html.getAttribute('data-theme') === 'dark') {
6 html.removeAttribute('data-theme');
7 localStorage.setItem('theme', 'light');
8 themeIcon.classList.remove('fa-moon');
9 themeIcon.classList.add('fa-sun');
10 } else {
11 html.setAttribute('data-theme', 'dark');
12 localStorage.setItem('theme', 'dark');
13 themeIcon.classList.remove('fa-sun');
14 themeIcon.classList.add('fa-moon');
15 }
16}
17
18function setTheme() {
19 const html = document.documentElement;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected