-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
56 lines (50 loc) · 1.87 KB
/
main.js
File metadata and controls
56 lines (50 loc) · 1.87 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
let myTimeout;
let flickeringTimeout;
const clickSound = new Audio('/sounds/click.mp3');
const flickeringSound = new Audio('/sounds/flicker.mp3');
let socialsElement = document.getElementsByClassName("buttons-container");
let textElement = document.getElementById("kmfid");
const bodyElement = document.body;
let bulbElement = document.getElementById('bulb');
function bulbActionFunction(){
const decider = document.getElementById('lightswitch');
if(decider.checked){
document.documentElement.style.setProperty('--backgroundOnOff', '#fff');
startBulb();
}
else{
document.documentElement.style.setProperty('--backgroundOnOff', 'rgb(73, 75, 88)');
stopBulb();
}
}
function stopBulb(){
clickSound.play();
flickeringSound.pause();
flickeringSound.currentTime = 0;
clearTimeout(myTimeout);
clearTimeout(flickeringTimeout);
for(let i = 0; i < socialsElement.length; i++)
socialsElement[i].style.display = 'none';
bulbElement.className = "off";
bodyElement.classList.remove("bg-light-flickering");
bodyElement.style.background = "rgb(11, 12, 26)";
textElement.style.display = "none";
}
function startBulb(){
clickSound.play();
bulbElement.className = "on";
bulbElement.classList.add("flickering");
bodyElement.style.removeProperty('background');
bodyElement.classList.add("bg-light-flickering");
textElement.style.display = "inline-block";
for(let i = 0; i < socialsElement.length; i++)
socialsElement[i].style.display = 'inline-block';
flickeringTimeout = setTimeout(function(){
flickeringSound.play();
}, 3000);
myTimeout = setTimeout(function(){
bulbElement.classList.remove("flickering");
bodyElement.classList.remove("bg-light-flickering");
bodyElement.style.background = "radial-gradient(circle, #bfdff3, #8eaec9)";
}, 5800);
}