forked from ridsuteri/Awesome-Chrome-Extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnav.js
41 lines (38 loc) · 1.02 KB
/
nav.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
$(document).ready(function () {
$(window).scroll(function () {
if ($(this).scrollTop() >= 100) {
$(".scrollToTop").fadeIn();
} else {
$(".scrollToTop").fadeOut();
}
});
$(".scrollToTop").click(function (e) {
e.preventDefault();
$("html, body").animate({ scrollTop: 0 }, 500);
return false;
});
});
function toggleDarkLight() {
var body = document.getElementById("body");
var button = document.getElementById("toggle");
if (button.innerHTML == "🌙") {
button.innerHTML = "☀️";
} else {
button.innerHTML = "🌙";
}
var trans = () => {
document.documentElement.classList.add("transition");
window.setTimeout(() => {
document.documentElement.classList.remove("transition");
}, 500);
};
var currentClass = body.className;
// body.className = currentClass == "dark-mode" ? "light-mode" : "dark-mode";
if (currentClass == "dark-mode") {
trans();
body.className = "light-mode";
} else {
trans();
body.className = "dark-mode";
}
}