forked from avinash201199/stopwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.js
52 lines (46 loc) · 1.46 KB
/
jquery.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function setLightTheme() {
$('.navbar.navbar-expand-lg.navbar-light').addClass('bg-light');
$('#title1').css({ "color": "black" });
$('body').css({ "background": "linear-gradient(to right, #191654, #43C6AC)" })
$('.digit').css({ "color": "white" })
$('#light').prop("checked", false);
}
function setDarkTheme() {
$('.navbar.navbar-expand-lg.navbar-light').removeClass('bg-light');
$('.navbar.navbar-expand-lg.navbar-light').css({ "background-color": "black" });
$('#title1').css({ "color": "white" });
$('body').css({ "background": "#191212" });
$('.digit').css({ "color": "rgb(216 137 31)" });
$('#light').prop("checked", true);
}
var prefersDarkThemeMql = window.matchMedia("(prefers-color-scheme: dark)");
prefersDarkThemeMql.addEventListener("change", function(mql) {
if (localStorage.getItem("darkmode") === null && mql.matches) {
setDarkTheme();
} else {
setLightTheme();
}
})
$(document).ready(function ()
{
if (
localStorage.getItem("darkmode") == "true" ||
(localStorage.getItem("darkmode") === null && prefersDarkThemeMql.matches)
)
{
setDarkTheme();
}
$('#light').on("change paste keyup", function (e)
{
if (!e.target.checked)
{
setLightTheme();
localStorage.setItem("darkmode", false);
}
else
{
setDarkTheme();
localStorage.setItem("darkmode", true);
}
});
});