-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
149 lines (140 loc) · 4.45 KB
/
script.js
File metadata and controls
149 lines (140 loc) · 4.45 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
const darkThemeMq = window.matchMedia("(prefers-color-scheme: dark)");
if (darkThemeMq.matches) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
document.getElementById('TSW1').checked = true;
document.getElementById('TSW2').checked = true;
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
function switchTheme(state) {
if(state){
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
function ST1(){
var TSW1 = document.getElementById('TSW1').checked;
document.getElementById('TSW2').checked = TSW1;
switchTheme(TSW1);
}
function ST2(){
var TSW2 = document.getElementById('TSW2').checked;
document.getElementById('TSW1').checked = TSW2;
switchTheme(TSW2);
}
if(window.navigator.language.split("-")[0] == "en"){
document.documentElement.setAttribute('lang', 'en');
}else{
document.documentElement.setAttribute('lang', 'th');
document.getElementById('LSW1').checked = true;
document.getElementById('LSW2').checked = true;
}
function switchLang(state) {
if(state){
document.documentElement.setAttribute('lang', 'th');
} else {
document.documentElement.setAttribute('lang', 'en');
}
}
function SL1(){
var LSW1 = document.getElementById('LSW1').checked;
document.getElementById('LSW2').checked = LSW1;
switchLang(LSW1);
}
function SL2(){
var LSW2 = document.getElementById('LSW2').checked;
document.getElementById('LSW1').checked = LSW2;
switchLang(LSW2);
}
window.onscroll = function() {
stickScroll()
};
var sticky = navbar.offsetTop;
function stickScroll() {
var navbar = document.getElementById("navbar");
var drop = document.getElementById("dc");
if (window.pageYOffset >= sticky) {
navbar.classList.remove("n");
navbar.classList.add("sticky");
drop.classList.remove("dct");
} else {
navbar.classList.remove("sticky");
navbar.classList.add("n");
drop.classList.add("dct");
}
}
function Nav() {
var menubtns = document.getElementById("menubtns").classList;
if(document.getElementById("Sidenav").style.width == 0 || document.getElementById("Sidenav").style.width == "0px") {
document.getElementById("Sidenav").style.width = "100%";
document.getElementById("main").style.display = "none";
menubtns.add("active");
menubtns.remove("not-active");
}else{
document.getElementById("Sidenav").style.width = "0";
document.getElementById("main").style.display = "block";
menubtns.add("not-active");
menubtns.remove("active");
}
}
let slideIndex1 = 1;
let slideIndex2 = 1;
showSlides(slideIndex1, '1');
showSlides(slideIndex2, '2');
function plusSlides(n, SID) {
if(SID == '1'){
showSlides(slideIndex1 += n, SID);
}else if(SID == '2'){
showSlides(slideIndex2 += n, SID);
}
}
function currentSlide(n, SID) {
if(SID == '1'){
showSlides(slideIndex1 = n, SID);
}else if(SID == '2'){
showSlides(slideIndex2 = n, SID);
}
}
function showSlides(n, SID) {
let i;
let ss = "s"+SID;
let dd = "d"+SID;
let slides = document.getElementsByClassName(ss);
let dots = document.getElementsByClassName(dd);
if(SID == '1'){
if (n > slides.length){
slideIndex1 = 1;
}
if (n < 1){
slideIndex1 = slides.length;
}
for (i = 0; i < slides.length; i++){
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++){
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex1-1].style.display = "block";
dots[slideIndex1-1].className += " active";
}else if(SID == '2'){
if (n > slides.length){
slideIndex2 = 1;
}
if (n < 1){
slideIndex2 = slides.length;
}
for (i = 0; i < slides.length; i++){
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++){
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex2-1].style.display = "block";
dots[slideIndex2-1].className += " active";
}
}