-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
35 lines (27 loc) · 877 Bytes
/
main.js
File metadata and controls
35 lines (27 loc) · 877 Bytes
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
/*const lamps =document.querySelectorAll(".lamp");
console.log(lamps);
let activeLight = 0;
setInterval(() => {
changeLight();
}, 1500);
function changeLight() {
lamps[activeLight].className = "lamp";
activeLight++;
if(activeLight > 2){
activeLight = 0;
}
const currentLight = lamps[activeLight];
currentLight.classList.add(currentLight.getAttribute("color"))
}*/
const $lamps = [...document.querySelectorAll('.lamp')];
const numberLamp = [0, 1, 2, 1];
numberLamp.forEach ( number => {
let currentLight = $lamps[number];
let secounds = +$lamps[number].dataset['mksecounds'];
let color = $lamps[number].dataset['color'];
currentLight.classList.add(`${color}`);
setTimeout(paintRemove(currentLight), secounds);
});
function paintRemove(domElement) {
domElement.className = 'lamp';
}