-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
74 lines (64 loc) · 2.12 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
let nightSky = document.getElementById('nightSky');
let starsContainer;
let ismoonthere;
let moon;
numberOfStars = 200;
function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function createStars() {
for (let i = 0; i < numberOfStars; i++) {
const star = document.createElement('div');
star.className = 'star';
star.style.right = `${getRandomNumber(0, 100)}%`;
star.style.top = `${getRandomNumber(0, 100)}%`;
nightSky.appendChild(star);
}
setTimeout(recreateStars, 9999);
}
function recreateStars() {
if(!ismoonthere){
for (let i = 0; i < numberOfStars / 20; i++) {
const star = document.createElement('div');
star.className = 'star';
star.style.right = `${getRandomNumber(0, 100)}%`;
star.style.top = `${getRandomNumber(0, 100)}%`;
nightSky.appendChild(star);
}
setTimeout(destroyStars, 4999);
}
}
function destroyStars() {
if(!ismoonthere){
for (let i = 0; i < numberOfStars / 20; i++) {
del = getRandomNumber(0, nightSky.childElementCount - 1);
nightSky.removeChild(nightSky.childNodes[del]);
}
setTimeout(recreateStars, 9999);
}
}
window.onload = createStars;
function showpasswd(){
let pass=document.getElementById('passwordIn')
let eye=document.getElementById('eye')
let login=document.getElementById('login-box')
if (pass.type === 'password'){
nightSky.innerHTML='';
moon=document.createElement('div');
moon.className = 'moon';
nightSky.appendChild(moon);
nightSky.classList.add('paused');
login.classList.add('paused');
pass.type='text';
ismoonthere=true;
}
else{
ismoonthere=false;
nightSky.removeChild(moon);
nightSky.classList.remove('paused');
login.classList.remove('paused');
pass.type='password';
createStars();
}
eye.src = (pass.type === 'password') ? 'eye1.png' : 'eye2.png';
}