-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (57 loc) · 2.27 KB
/
script.js
File metadata and controls
65 lines (57 loc) · 2.27 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
document.addEventListener('DOMContentLoaded', function () {
const btnLogin = document.getElementById('btnLogin');
const loginForm = document.getElementById('loginForm');
const btnSubmitLogin = document.getElementById('btnSubmitLogin');
const btnCloseLogin = document.getElementById('btnCloseLogin');
const box = document.getElementById('box');
const resultBox = document.getElementById('resultBox');
const startButton = document.getElementById('startButton');
let startTime, endTime;
function getRandomTime() {
return Math.floor(Math.random() * (3000 - 1000) + 1000);
}
function displayBox() {
overlay.style.zIndex= 0;
box.style.zIndex = 2;
box.style.backgroundColor = '#6b0000';
box.style.cursor = 'pointer';
box.textContent = 'CLICK!';
startTime = new Date();
}
function hideBox() {
overlay.style.zIndex= 3;
box.style.zIndex = 2;
box.style.backgroundColor = '#84ff65';
box.textContent = '';
box.style.cursor = 'default';
setTimeout(displayBox, getRandomTime());
}
btnLogin.addEventListener('click', function () {
loginForm.style.display = 'block';
});
btnSubmitLogin.addEventListener('click', function () {
alert('The Feature Has not Been Implemented Yet...');
loginForm.style.display = 'none';
});
btnCloseLogin.addEventListener('click', function () {
loginForm.style.display = 'none';
});
function handleBoxClick() {
endTime = new Date();
const reactionTime = endTime - startTime;
resultBox.textContent = `Your reaction time Was: ${reactionTime - 40} milliseconds With Ping: ${reactionTime}`;
box.style.zIndex = 1;
resultBox.classList.remove('hidden');
startButton.removeAttribute('disabled');
}
function handleStartClick() {
resultBox.classList.add('hidden');
startButton.setAttribute('disabled', true);
hideBox();
}
box.addEventListener('click', handleBoxClick);
startButton.addEventListener('click', handleStartClick);
btnLogin.addEventListener('click', function () {
loginForm.style.display = 'block';
});
});