PageSourceSearch

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

js yashpant.github.io collected 2026-10-03 10:12:35 UTC 914 bytes, 34 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("light");
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        }, 500)
33    }
34});

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.