-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
94 lines (90 loc) · 2.79 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const btnsContaner = document.querySelector(".contanerbtn");
const mods = document.querySelectorAll(".butens");
const mode1 = document.querySelector(".btn1");
const mode2 = document.querySelector(".btn2");
const contaner = document.querySelector(".boxparenret");
const boxes = document.querySelectorAll(".box");
const backdoor = document.querySelector(".backdoor");
// for removing the items and replase
const remover = function () {
contaner.classList.remove("hide");
backdoor.classList.remove("hide");
btnsContaner.classList.add("hide");
};
// to relode the page and reset the functionality
const backward = function () {
backdoor.addEventListener("click", function (e) {
e.preventDefault();
location.reload();
backdoor.classList.add("hide");
btnsContaner.classList.remove("hide");
contaner.classList.add("hide");
});
};
// to choose betwen the mods
const modschanger = function () {
mods.forEach(function (value, index) {
value.addEventListener("click", function (e) {
if (e.target.classList.contains("btn1")) {
remover();
manual();
} else {
remover();
Automatic();
}
});
});
};
// ---------------- manual model ----------------------
const manual = () => {
boxes.forEach(function (value, index) {
const colorchanger = function () {
const x = (max, min) => {
return Math.floor(Math.random() * max) + min;
};
value.style.backgroundColor = `rgb(${x(255, 1)},${x(255, 1)},${x(
255,
1
)})`;
value.style.borderRadius = 10 + "px";
};
value.addEventListener("mouseover", colorchanger);
value.addEventListener("mouseout", function () {
value.style.borderRadius = Math.floor(Math.random() * 100) + 10 + "px";
});
});
};
// ---------------- Automatic model -------------------
const Automatic = () => {
boxes.forEach(function (value, index) {
const colorchanger = function () {
// to get accsess the color random foreath of the box's
const x = (max, min) => {
return Math.floor(Math.random() * max) + min;
};
// for set the time
const timer = 1000;
setInterval(
() =>
// colorise the cube's
(value.style.backgroundColor = `rgb(${x(255, 1)},${x(255, 1)},${x(
255,
1
)})`),
timer
);
setInterval(
() =>
// set the redus for shape shifting
(value.style.borderRadius =
Math.floor(Math.random() * 100) + 10 + "px"),
timer
);
// setInterval(()=> value.style.borderRadius = 10 + "px" , 1000)
};
colorchanger();
});
};
// calling the metods to working as fuck yaaaaaaa🤞
modschanger();
backward();