-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
205 lines (183 loc) · 6.47 KB
/
Copy pathscript.js
File metadata and controls
205 lines (183 loc) · 6.47 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
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
201
202
203
204
const email = document.querySelector('#email');
const username = document.querySelector('#username');
const password = document.querySelector('#password');
const confirm_password = document.querySelector('#confirm-password');
const policy = document.querySelector('#confirm-policy')
const not_a_robot = document.querySelector('#not-a-robot');
const cta_btn = document.querySelector('#cta-btn');
const showPassword = document.querySelector('#pass-show-ico');
const hidePassword = document.querySelector('#pass-hide-ico')
const Confirm_showPassword = document.querySelector('#con-pass-show-ico');
const Confirm_hidePassword = document.querySelector('#con-pass-hide-ico');
let password_flag = false;
let confirm_password_flag = false;
function main() {
events();
}
main()
function events() {
cta_btn.disabled = true;
email.addEventListener('keyup', (e) => {
validateEmail();
email.value === '' ? setSuccess(email, '') : '';
})
password.addEventListener('keyup', (e) => {
validatePassword();
})
confirm_password.addEventListener('keyup', (e) => {
if (password.value !== '') {
password.value === confirm_password.value ? setSuccess(confirm_password, '') : setError(confirm_password, `Password doesn't match!`)
}
confirm_password.value === '' ? setSuccess(confirm_password, '') : '';
})
policy.addEventListener('change', (e) => {
policy.checked ? cta_btn.disabled = false : cta_btn.disabled = true;
const nextElement = policy.parentElement.nextElementSibling;
if (nextElement) {
nextElement.focus();
}
})
not_a_robot.addEventListener('change', (e) => {
const nextElement = not_a_robot.parentElement.nextElementSibling;
if (nextElement) {
nextElement.focus();
}
})
cta_btn.addEventListener('click', (e) => {
e.preventDefault();
window.open('./success.html', '_self');
})
// Password Show hide
password.addEventListener('input', () => { showHide(password, showPassword, hidePassword, password_flag) })
confirm_password.addEventListener('input', () => { showHide(confirm_password, Confirm_showPassword, Confirm_hidePassword, confirm_password_flag) })
showPassword.addEventListener('click', () => {
password.type = 'text';
showPassword.style.visibility = 'hidden';
hidePassword.style.visibility = 'visible'
})
hidePassword.addEventListener('click', () => {
password.type = 'password';
showPassword.style.visibility = 'visible';
hidePassword.style.visibility = 'hidden'
})
Confirm_showPassword.addEventListener('click', () => {
confirm_password.type = 'text';
Confirm_showPassword.style.visibility = 'hidden';
Confirm_hidePassword.style.visibility = 'visible'
})
Confirm_hidePassword.addEventListener('click', () => {
confirm_password.type = 'password';
Confirm_showPassword.style.visibility = 'visible';
Confirm_hidePassword.style.visibility = 'hidden'
})
}
function validateEmail() {
email.value.match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/) ? setSuccess(email, '') : setError(email, 'Enter Valid Email');
}
// function validateUsername() { }
function validatePassword() {
password.value.match(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{8,}$/) ? setSuccess(password, '') : setError(password,
`Enter a password with uppercase, lowercase, numbers, and symbols.`)
password.value === '' ? setSuccess(password, '') : '';
}
// function show-hide password
function showHide(input, show, hide, flag) {
if (input.value.trim() !== '') {
if (flag == false) {
show.style.visibility = 'visible';
hide.style.visibility = 'hidden';
flag = true;
} else {
show.style.visibility = 'hidden';
hide.style.visibility = 'visible';
flag = false;
}
} else {
show.style.visibility = 'hidden';
hide.style.visibility = 'hidden';
}
}
function setError(item, msg) {
let Element = item.closest(".form-elements").querySelector(".error");
Element.textContent = msg;
return false;
}
function setSuccess(item, msg) {
let Element = item.closest(".form-elements").querySelector(".error");
Element.innerHTML = msg;
return true;
}
// Slider Code
let FrameInterval;
let index = 0;
let duration = 5000;
let imageInterval;
let progressBar = document.querySelector('#progress1');
let normalContent = document.querySelector('#content1')
const sliderContent = document.querySelector('#content-slide');
const watch_demo = document.querySelector('#watch-demo');
const close_slide = document.querySelector('#close-slide')
const slide = document.querySelector('#slide');
watch_demo.addEventListener('click', (e) => {
normalContent.parentElement.classList.add('video')
normalContent.style.display = 'none';
sliderContent.style.display = 'block';
animation();
move();
})
close_slide.addEventListener('click', (e) => {
normalContent.parentElement.classList.remove('video')
normalContent.style.display = 'block';
sliderContent.style.display = 'none';
clearInterval(imageInterval);
clearInterval(FrameInterval);
progressBar.style.width = '0%';
})
document.querySelector('#slides').addEventListener('click', (e) => {
e.preventDefault();
clearInterval(imageInterval);
clearInterval(FrameInterval);
progressBar.style.width = '0%';
changeImage();
animation();
})
function animation() {
imageInterval = setInterval(changeImage, duration)
}
function changeImage() {
let src = [
'./static/2.jpg',
'./static/4.jpg',
'./static/5.jpg',
'./static/6.jpg',
'./static/1.jpg',
];
slide.classList.remove('active');
if (index >= src.length) index = 0;
setTimeout(() => {
move()
slide.src = src[index];
index++;
setTimeout(() => {
slide.classList.add('active');
}, 100);
}, 500);
}
function move() {
let width = 0;
let stepTime = duration / 100;
if (FrameInterval) {
clearInterval(FrameInterval); // Prevent multiple intervals
}
FrameInterval = setInterval(frame, stepTime);
// increase Width
function frame() {
if (width >= 100) {
clearInterval(FrameInterval);
progressBar.style.width = '0%';
} else {
width++;
progressBar.style.width = width + "%";
}
}
}