-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
76 lines (66 loc) · 2.06 KB
/
script.js
File metadata and controls
76 lines (66 loc) · 2.06 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Nav bar
function openNav() {
document.getElementById("nav").style.width = "270px";
}
function closeNav() {
document.getElementById("nav").style.width = "0";
}
// Slides
var slideIndex = [1, 1, 1, 1];
var slideId = ["slide0", "slide1", "slide2", "slide3"]
showSlides(1, 0);
showSlides(1, 1);
showSlides(1, 2);
showSlides(1, 3);
function chSlide(n, no) {
showSlides(slideIndex[no] += n, no);
}
function showSlides(n, no) {
var i;
var x = document.getElementsByClassName(slideId[no]);
if (n > x.length) {slideIndex[no] = 1}
if (n < 1) {slideIndex[no] = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex[no]-1].style.display = "block";
}
// Light/dark mode
function chLight() {
var mode = document.getElementById("chBtn").getAttribute("src")
if (mode == "images/light.png") {
document.getElementById("chBtn").src = "images/dark.png";
document.body.style.backgroundColor = "white";
document.body.style.color = "black";
} else {
document.getElementById("chBtn").src = "images/light.png";
document.body.style.backgroundColor = "#333333";
document.body.style.color = "white";
}
}
// Auto set light/dark w/ local time
var time = new Date();
var hr = time.getHours();
if (7 < hr && hr < 19) {
document.getElementById("chBtn").src = "images/dark.png";
document.body.style.backgroundColor = "white";
document.body.style.color = "black";
} else {
document.getElementById("chBtn").src = "images/light.png";
document.body.style.backgroundColor = "#333333";
document.body.style.color = "white";
}
// Return to top
var t_button = document.getElementById("topBtn");
window.onscroll = function() {scroll_func()};
function scroll_func() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
t_button.style.display = "block";
} else {
t_button.style.display = "none";
}
}
function r_top() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}