-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
195 lines (163 loc) · 5.24 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
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
/* Toggle Menu */
const body = document.querySelector("mainwrapper");
const nav = document.querySelector("nav");
const sidebarOpen = document.querySelector(".sidebarOpen");
const sidebarClose = document.querySelector(".sidebarClose");
const mainwrapper = document.querySelector(".mainwrapper");
// Function to open the sidebar
function openSidebar() {
nav.classList.add("active");
}
// Function to close the sidebar
function closeSidebar() {
nav.classList.remove("active");
}
sidebarOpen.addEventListener("click", openSidebar);
sidebarClose.addEventListener("click", closeSidebar);
mainwrapper.addEventListener("click", (e) => {
let clickedElm = e.target;
if (
!clickedElm.classList.contains("sidebarOpen") &&
!clickedElm.classList.contains("menu")
) {
closeSidebar(); // Close the sidebar when clicking outside
}
});
// /* Event listener */
// toggle.addEventListener("click", toggleNavMenu, false);
// slider banner
const slides = document.querySelectorAll(".slide-container");
let index = 0;
// next
function next() {
slides[index].classList.remove("active2");
index = (index + 1) % slides.length;
slides[index].classList.add("active2");
}
// prev
function prev() {
slides[index].classList.remove("active2");
index = (index - 1 + slides.length) % slides.length;
slides[index].classList.add("active2");
}
// autoplay
setInterval(next, 6000);
// Pas Validator
var lockIcon = document.querySelector(".fa-lock");
var password = document.querySelector("#pass");
var state = false;
let text, validIcons, invalidIcons;
function toggle() {
myFunction();
if (state) {
function displayPass() {
document.getElementById("pass").setAttribute("type", "password");
}
setTimeout(displayPass, 80);
state = false;
} else {
function displayText() {
document.getElementById("pass").setAttribute("type", "text");
}
setTimeout(displayText, 80);
state = true;
}
}
function myFunction() {
var eye = document.querySelector(".eye-close");
imgsrc = document.getElementById("img1").src;
if (imgsrc.indexOf("eye-close") != -1) {
eye.classList.add("eye-open");
document.getElementById("img1").src =
"https://i.postimg.cc/3JHFrZ3v/eye-open.png";
} else {
eye.classList.remove("eye-open");
document.getElementById("img1").src =
"https://i.postimg.cc/HWMtCN1m/eye-close.png";
}
}
// checkpass
function textChange() {
var password = document.getElementById("pass").value;
var capital = document.getElementById("capital");
var specialChar = document.getElementById("special-char");
var number = document.getElementById("number");
var moreThan8 = document.getElementById("more-than-8");
// Check for uppercase letter
if (/[A-Z]/.test(password)) {
capital.querySelector(".fa-check").style.opacity = "1";
capital.querySelector(".fa-times").style.opacity = "0";
} else {
capital.querySelector(".fa-check").style.opacity = "0";
capital.querySelector(".fa-times").style.opacity = "1";
}
// Check for special character
if (/[!@#$%^&*]/.test(password)) {
specialChar.querySelector(".fa-check").style.opacity = "1";
specialChar.querySelector(".fa-times").style.opacity = "0";
} else {
specialChar.querySelector(".fa-check").style.opacity = "0";
specialChar.querySelector(".fa-times").style.opacity = "1";
}
// Check for number
if (/\d/.test(password)) {
number.querySelector(".fa-check").style.opacity = "1";
number.querySelector(".fa-times").style.opacity = "0";
} else {
number.querySelector(".fa-check").style.opacity = "0";
number.querySelector(".fa-times").style.opacity = "1";
}
// Check for length greater than or equal to 8
if (password.length >= 8) {
moreThan8.querySelector(".fa-check").style.opacity = "1";
moreThan8.querySelector(".fa-times").style.opacity = "0";
} else {
moreThan8.querySelector(".fa-check").style.opacity = "0";
moreThan8.querySelector(".fa-times").style.opacity = "1";
}
}
// Translate
function googleTranslateElementInit() {
new google.translate.TranslateElement(
{ pageLanguage: "en" },
"google_translate_element"
);
}
// Cookie
const cookieBox = document.querySelector(".cookiewrapper"),
buttons = document.querySelectorAll(".cbtn");
console.log(cookieBox, buttons);
const executeCodes = () => {
// if (document.cookie.includes("GWSC")) return;
cookieBox.classList.add("show");
buttons.forEach((button) => {
button.addEventListener("click", () => {
cookieBox.classList.remove("show");
// for accept
if (button.id == "acceptBtn") {
//duration
document.cookie = "cookieBy= GWSC; max-age = " + 60 * 60 * 24;
}
});
});
};
//executeCodes function will be called on webpage load
window.addEventListener("load", executeCodes);
// Scroll to top
// Get the button
let topbtn = document.getElementById("topbtn");
// Listen to the scroll event on the window
window.onscroll = function () {
scrollFunction();
};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
topbtn.style.display = "block"; // Show the button
} else {
topbtn.style.display = "none"; // Hide the button
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}