-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #674 from colinpeddle/darkmode
Darkmode
- Loading branch information
Showing
19 changed files
with
1,133 additions
and
702 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
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,40 @@ | ||
// will create a dark mode and store status in local storage | ||
|
||
// Check if the dark mode status is stored in localStorage | ||
var darkModeToggle = document.getElementById("darkModeToggle"); | ||
|
||
if (localStorage.getItem("darkModeStatus")) { | ||
// Update the dark mode toggle switch and status text | ||
darkModeToggle.checked = localStorage.getItem("darkModeStatus") === "On"; | ||
|
||
// Set dark mode immediately based on stored status | ||
toggleDarkMode(); | ||
} | ||
|
||
function toggleDarkMode() { | ||
var sliderElement = darkModeForm.querySelector(".slider"); | ||
if (darkModeToggle.checked) { | ||
// Dark Mode is On | ||
document.documentElement.classList.add("darkmode"); | ||
localStorage.setItem("darkModeStatus", "On"); | ||
sliderElement.classList.remove("moon"); | ||
sliderElement.classList.add("sun"); | ||
} else { | ||
// Dark Mode is Off | ||
document.documentElement.classList.remove("darkmode"); | ||
localStorage.setItem("darkModeStatus", "Off"); | ||
sliderElement.classList.remove("sun"); | ||
sliderElement.classList.add("moon"); | ||
} | ||
} | ||
|
||
// move to admin or elsewhere afterward | ||
document.addEventListener("DOMContentLoaded", function () { | ||
const topNavIcon = document.querySelector(".topnavicon"); | ||
|
||
topNavIcon.addEventListener("click", function () { | ||
topNavIcon.classList.toggle("show-before"); | ||
const afterIcon = topNavIcon.nextElementSibling; | ||
afterIcon.style.display = afterIcon.style.display === "none" ? "inline" : "none"; | ||
}); | ||
}); |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,63 +1,74 @@ | ||
|
||
function topNav() { | ||
var x = document.getElementById("topnav"); | ||
if (x.className === "topnav") { | ||
x.className += " responsive"; | ||
} else { | ||
x.className = "topnav"; | ||
} | ||
var x = document.getElementById("topnav"); | ||
if (x.className === "topnav") { | ||
x.className += " responsive"; | ||
} else { | ||
x.className = "topnav"; | ||
} | ||
} | ||
|
||
function togglePlainText(id) { | ||
var x = document.getElementById(id); | ||
if (x.type === "password") { | ||
x.type = "text"; | ||
} else { | ||
x.type = "password"; | ||
} | ||
var x = document.getElementById(id); | ||
if (x.type === "password") { | ||
x.type = "text"; | ||
} else { | ||
x.type = "password"; | ||
} | ||
} | ||
|
||
function validatePassword(id) { | ||
var x = document.getElementById(id); | ||
if (x.value == "<enter password>") { | ||
alert("Please enter a password to continue."); | ||
return false; | ||
} | ||
return true; | ||
var x = document.getElementById(id); | ||
if (x.value == "<enter password>") { | ||
alert("Please enter a password to continue."); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
// Function to update the displayed number | ||
function updateNumber(opt, parent) { | ||
var parentElement = parent.parentElement; | ||
var numDisplay = parentElement.querySelector(".numDisplay"); | ||
var number = parseInt(numDisplay.textContent); | ||
if (opt == "up") number += 1; | ||
if (opt == "dn") number -= 1; | ||
numDisplay.textContent = number; | ||
} | ||
|
||
function increaseNumber(id) { | ||
var x = document.getElementById(id); | ||
var val = Number(x.value); | ||
var max = x.max; | ||
if (max > val) { | ||
val += 1; | ||
x.value = val; | ||
} | ||
var x = document.getElementById(id); | ||
var val = Number(x.value); | ||
var max = x.max; | ||
if (max > val) { | ||
val += 1; | ||
x.value = val; | ||
} | ||
var opt = "up"; | ||
updateNumber(opt, x); | ||
} | ||
|
||
function decreaseNumber(id) { | ||
var x = document.getElementById(id); | ||
var val = Number(x.value); | ||
var min = x.min; | ||
if (min < val) { | ||
val -= 1; | ||
x.value = val; | ||
} | ||
var x = document.getElementById(id); | ||
var val = Number(x.value); | ||
var min = x.min; | ||
if (min < val) { | ||
val -= 1; | ||
x.value = val; | ||
} | ||
var opt = "dn"; | ||
updateNumber(opt, x); | ||
} | ||
|
||
function buttonConfirm(elem, text='', timeout=3, reset=true) | ||
{ | ||
var originalText = elem.innerHTML; | ||
function buttonConfirm(elem, text = "", timeout = 3, reset = true) { | ||
var originalText = elem.innerHTML; | ||
|
||
elem.innerHTML = (text == '' ? '✓' : text); | ||
elem.disabled = true; | ||
elem.innerHTML = text == "" ? "✓" : text; | ||
elem.disabled = true; | ||
|
||
if (reset) | ||
{ | ||
setTimeout(function(){ | ||
elem.innerHTML = originalText; | ||
elem.disabled = false; | ||
}, timeout*1000); | ||
} | ||
if (reset) { | ||
setTimeout(function () { | ||
elem.innerHTML = originalText; | ||
elem.disabled = false; | ||
}, timeout * 1000); | ||
} | ||
} |
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
Oops, something went wrong.