-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
39 lines (31 loc) · 1.01 KB
/
Copy pathscript.js
File metadata and controls
39 lines (31 loc) · 1.01 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
const startButton = document.querySelector(".start-button button");
const listItems = document.querySelectorAll("li");
const resultDiv = document.querySelector(".result");
const startButtonContainer = document.querySelector(".start-button");
function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function activateListItem(item, index) {
return new Promise((resolve) => {
setTimeout(() => {
item.classList.add("active");
console.log(`Activated item ${index + 1}`);
resolve();
}, 500);
});
}
function refreshPage() {
window.location.reload();
}
startButton.addEventListener("click", async () => {
startButton.textContent = "درحال بارگیری ...";
startButton.disabled = true;
startButton.style.cursor = "not-allowed";
for (let i = 0; i < listItems.length; i++) {
await activateListItem(listItems[i], i);
}
await delay(1000);
startButtonContainer.style.display = "none";
resultDiv.style.display = "flex";
});
window.refreshPage = refreshPage;