forked from codrineugeniu/git-workshop-fe8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
65 lines (59 loc) · 1.37 KB
/
main.js
File metadata and controls
65 lines (59 loc) · 1.37 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
let h, s, l;
const helloInDifLanguage = [
"Ahlan",
"Zdrasti",
"Hey",
"Salut",
"Hallo",
"Salam!",
"Ciao",
"Oi",
"Hei",
"Selam",
"Helo",
"Yasou",
];
let sayHello;
let helloStyle = document.querySelector("#hello-container");
function getRandomHello() {
sayHello = helloInDifLanguage[Math.floor(Math.random() * 12)];
}
function displayHello() {
getRandomHello();
helloStyle.innerHTML = sayHello;
helloStyle.style.color = `hsl(${h + 180}, ${s}%, ${l}%)`;
}
function randomHSLValues() {
h = Math.floor(Math.random() * 360);
s = Math.floor(Math.random() * 21 + 80);
l = Math.floor(Math.random() * 11 + 55);
}
// const timerID = [];
let timeID;
function executeHello() {
timeID = setTimeout(function () {
changeColor();
displayHello();
console.log(sayHello);
executeHello();
}, 3000);
// timerID.push(timeID);
}
executeHello();
let selectBody = document.querySelector("body");
function changeColor() {
randomHSLValues();
helloStyle.style.background = `hsl(${h}, ${s}%, ${l}%)`;
helloStyle.style.borderColor = `hsl(${h}, ${s - 10}%, ${l - 20}%)`;
}
function handleClick() {
if (timeID) {
clearTimeout(timeID);
timeID = 0;
} else console.log(`Stop: timeout id is ${timeID}`);
}
var btn = document.querySelector("#first-btn");
btn.addEventListener("click", handleClick);
function conflictsAreUgly() {
console.log("🙏");
}