-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
200 lines (179 loc) · 6.52 KB
/
main.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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//
// ██╗░░░██╗██╗███╗░░██╗░█████╗░██████╗░
// ██║░░░██║██║████╗░██║██╔══██╗██╔══██╗
// ╚██╗░██╔╝██║██╔██╗██║██║░░██║██║░░██║
// ░╚████╔╝░██║██║╚████║██║░░██║██║░░██║
// ░░╚██╔╝░░██║██║░╚███║╚█████╔╝██████╔╝
// ░░░╚═╝░░░╚═╝╚═╝░░╚══╝░╚════╝░╚═════╝░
// ░░░░░██╗░█████╗░███╗░░██╗░██████╗░██╗██████╗░
// ░░░░░██║██╔══██╗████╗░██║██╔════╝░██║██╔══██╗
// ░░░░░██║███████║██╔██╗██║██║░░██╗░██║██║░░██║
// ██╗░░██║██╔══██║██║╚████║██║░░╚██╗██║██║░░██║
// ╚█████╔╝██║░░██║██║░╚███║╚██████╔╝██║██████╔╝
// ░╚════╝░╚═╝░░╚═╝╚═╝░░╚══╝░╚═════╝░╚═╝╚═════╝░
// preloader script............
var audio = document.getElementById("audioPlayer");
var loader = document.getElementById("preloader");
window.addEventListener("load", function () {
loader.style.display = "none";
});
// preloader script ends here.........
// switch for setting
function settingtoggle() {
document
.getElementById("setting-container")
.classList.toggle("settingactivate");
document
.getElementById("visualmodetogglebuttoncontainer")
.classList.toggle("visualmodeshow");
document
.getElementById("soundtogglebuttoncontainer")
.classList.toggle("soundmodeshow");
}
function playpause() {
if (document.getElementById("switchforsound").checked == false) {
audio.pause();
} else {
audio.play();
}
}
function visualmode() {
document.body.classList.toggle("light-mode");
var elements = document.querySelectorAll(".needtobeinvert");
elements.forEach(function (element) {
element.classList.toggle("invertapplied");
});
}
let emptyArea = document.getElementById("emptyarea");
let mobileTogglemenu = document.getElementById("mobiletogglemenu");
// toggle menu by clicking on hamburger
function hamburgerMenu() {
document.body.classList.toggle("stopscrolling");
document
.getElementById("mobiletogglemenu")
.classList.toggle("show-toggle-menu");
document
.getElementById("burger-bar1")
.classList.toggle("hamburger-animation1");
document
.getElementById("burger-bar2")
.classList.toggle("hamburger-animation2");
document
.getElementById("burger-bar3")
.classList.toggle("hamburger-animation3");
}
// close mobile toggle menu by clicking on LI
function hidemenubyli() {
document.body.classList.toggle("stopscrolling");
document
.getElementById("mobiletogglemenu")
.classList.remove("show-toggle-menu");
document
.getElementById("burger-bar1")
.classList.remove("hamburger-animation1");
document
.getElementById("burger-bar2")
.classList.remove("hamburger-animation2");
document
.getElementById("burger-bar3")
.classList.remove("hamburger-animation3");
}
const sections = document.querySelectorAll("section");
const navLi = document.querySelectorAll(
".navbar .navbar-tabs .navbar-tabs-ul li"
);
const mobilenavLi = document.querySelectorAll(
".mobiletogglemenu .mobile-navbar-tabs-ul li"
);
window.addEventListener("scroll", () => {
let current = "";
sections.forEach((section) => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (pageYOffset >= sectionTop - 200) {
current = section.getAttribute("id");
}
});
mobilenavLi.forEach((li) => {
li.classList.remove("activeThismobiletab");
if (li.classList.contains(current)) {
li.classList.add("activeThismobiletab");
}
});
navLi.forEach((li) => {
li.classList.remove("activeThistab");
if (li.classList.contains(current)) {
li.classList.add("activeThistab");
}
});
});
console.log(
"%c Designed and Developed by Vinod Jangid ",
"background-image: linear-gradient(90deg,#8000ff,#6bc5f8); color: white;font-weight:900;font-size:1rem; padding:20px;"
);
let mybutton = document.getElementById("backtotopbutton");
window.onscroll = function () {
scrollFunction();
};
function scrollFunction() {
if (
document.body.scrollTop > 400 ||
document.documentElement.scrollTop > 400
) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function scrolltoTopfunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
// document.addEventListener("contextmenu", function (e){
// e.preventDefault();
// }, false);
// https://github.com/vinodjangid07
document.addEventListener(
"contextmenu",
function (e) {
if (e.target.nodeName === "IMG") {
e.preventDefault();
}
},
false
);
let Pupils = document.getElementsByClassName("footer-pupil");
let pupilsArr = Array.from(Pupils);
let pupilStartPoint = -10;
let pupilRangeX = 20;
let pupilRangeY = 15;
// mouse X
let mouseXStartPoint = 0;
let mouseXEndPoint = window.innerWidth;
let currentXPosition = 0;
let fracXValue = 0;
// mouse Y position
let mouseYEndPoint = window.innerHeight;
let currentYPosition = 0;
let fracYValue = 0;
let mouseXRange = mouseXEndPoint - mouseXStartPoint;
const mouseMove = (event) => {
currentXPosition = event.clientX - mouseXStartPoint;
fracXValue = currentXPosition / mouseXRange;
currentYPosition = event.clientY;
fracYValue = currentYPosition / mouseYEndPoint;
// footer
let pupilXCurrrentPosition = pupilStartPoint + fracXValue * pupilRangeX;
let pupilYCurrrentPosition = pupilStartPoint + fracYValue * pupilRangeY;
// footer
pupilsArr.forEach((curPupil) => {
curPupil.style.transform = `translate(${pupilXCurrrentPosition}px, ${pupilYCurrrentPosition}px)`;
});
};
const windowResize = (event) => {
mouseXEndPoint = window.innerWidth;
mouseYEndPoint = window.innerHeight;
mouseXRange = mouseXEndPoint - mouseXStartPoint;
};
window.addEventListener("mousemove", mouseMove);
window.addEventListener("resize", windowResize);