-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.js
78 lines (58 loc) · 2.38 KB
/
script.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
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
const allSideMenu = document.querySelectorAll('#sidebar .side-menu.top li a');
allSideMenu.forEach(item=> {
const li = item.parentElement;
item.addEventListener('click', function () {
allSideMenu.forEach(i=> {
i.parentElement.classList.remove('active');
})
li.classList.add('active');
})
});
// TOGGLE SIDEBAR
const menuBar = document.querySelector('#content nav .bx.bx-menu');
const sidebar = document.getElementById('sidebar');
menuBar.addEventListener('click', function () {
sidebar.classList.toggle('hide');
})
const searchButton = document.querySelector('#content nav form .form-input button');
const searchButtonIcon = document.querySelector('#content nav form .form-input button .bx');
const searchForm = document.querySelector('#content nav form');
searchButton.addEventListener('click', function (e) {
if(window.innerWidth < 576) {
e.preventDefault();
searchForm.classList.toggle('show');
if(searchForm.classList.contains('show')) {
searchButtonIcon.classList.replace('bx-search', 'bx-x');
} else {
searchButtonIcon.classList.replace('bx-x', 'bx-search');
}
}
})
if(window.innerWidth < 768) {
sidebar.classList.add('hide');
} else if(window.innerWidth > 576) {
searchButtonIcon.classList.replace('bx-x', 'bx-search');
searchForm.classList.remove('show');
}
window.addEventListener('resize', function () {
if(this.innerWidth > 576) {
searchButtonIcon.classList.replace('bx-x', 'bx-search');
searchForm.classList.remove('show');
}
})
const switchMode = document.getElementById('switch-mode');
switchMode.addEventListener('change', function () {
if(this.checked) {
document.body.classList.add('dark');
document.getElementById("switch-mode").checked = true;
document.querySelector(".switch-mode").classList.add("test");
window.localStorage.setItem("state","dark")
} else {
document.body.classList.remove('dark');
document.getElementById("switch-mode").checked = false;
document.querySelector(".switch-mode").classList.remove("test");
window.localStorage.removeItem("state");
}
})
console.log('%c COMBook', 'font-weight: bold; font-size: 70px;color: red; text-shadow: 3px 3px 0 rgb(217,31,38) , 6px 6px 0 rgb(226,91,14) , 9px 9px 0 rgb(245,221,8) , 12px 12px 0 rgb(5,148,68) , 15px 15px 0 rgb(2,135,206) , 18px 18px 0 rgb(4,77,145) , 21px 21px 0 rgb(42,21,113)');
console.log(' ');