-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
splits dark mode loading and toggle. loads in header
- Loading branch information
1 parent
964cfd4
commit f80a70c
Showing
3 changed files
with
28 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Function to get the value of a cookie | ||
function getCookie(name) { | ||
var cookieName = name + "="; | ||
var decodedCookie = decodeURIComponent(document.cookie); | ||
var cookieArray = decodedCookie.split(";"); | ||
|
||
for (var i = 0; i < cookieArray.length; i++) { | ||
var cookie = cookieArray[i].trim(); // Remove leading/trailing spaces | ||
|
||
if (cookie.substring(0, cookieName.length) === cookieName) { | ||
return cookie.substring(cookieName.length, cookie.length); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
window.addEventListener("DOMContentLoaded", () => { | ||
if (getCookie("bj-dark-mode") === "true") { | ||
let button = document.getElementById("change-skin"); | ||
document.body.classList.add("page-dark-mode"); | ||
button.setAttribute("aria-checked", true); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters