PageSourceSearch

https://shahrasbi.github.io/assets/js/dark_mode.js

js shahrasbi.github.io collected 2026-10-03 09:56:07 UTC 959 bytes, 35 lines download raw bytes

1$(document).ready(function() {
2    const mode_toggle = document.getElementById("light-toggle");
3  
4    mode_toggle.addEventListener("click", function() {
5        const temp = localStorage.getItem('theme');
6        toggleTheme(temp);
7    });
8    
9    let toggleTheme = (theme) => {
10        if (theme == "dark") {
11            setTheme(null);
12        } else {
13            setTheme('dark');
14        }
15    }
16  
17    let setTheme = (theme) =>  {
18        trans();
19        if (theme) {
20            document.documentElement.setAttribute('data-theme', theme) 
21        }
22        else {
23            document.documentElement.removeAttribute('data-theme');
24        }
25        localStorage.setItem('theme', theme);
26    };
27  
28    let trans = () => {
29        document.documentElement.classList.add('transition');
30        window.setTimeout(() => {
31            document.documentElement.classList.remove('transition')
32        }, 1000)
33    }
34});
35  

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.