-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefuse-the-bom.html
More file actions
47 lines (37 loc) · 1.35 KB
/
defuse-the-bom.html
File metadata and controls
47 lines (37 loc) · 1.35 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
<html><head>
<meta charset="utf-8">
<title>Defuse the BOM</title>
</head>
<body data-new-gr-c-s-check-loaded="14.1093.0" data-gr-ext-installed="">
<h2 id="message">This BOM will self destruct in <span id="timer">5</span> seconds...</h2>
<button id="defuser">Defuse the BOM</button>
<script>
(function() {
"use strict";
let detonationTimer = 5;
// TODO: This function needs to be called once every second
function updateTimer() {
if (detonationTimer == 0) {
alert('EXTERMINATE!');
document.body.innerHTML = '';
} else if (detonationTimer > 0) {
document.getElementById('timer').innerHTML = detonationTimer;
}
detonationTimer--;
}
let intervalId = setInterval(updateTimer, 1000);
// TODO: When this function runs, it needs to
// cancel the interval/timeout for updateTimer()
function defuseTheBOM() {
clearInterval(intervalId);
}
// Don't modify anything below this line!
//
// This causes the defuseTheBOM() function to be called
// when the "defuser" button is clicked.
// We will learn about events in the DOM lessons
var defuser = document.getElementById('defuser');
defuser.addEventListener('click', defuseTheBOM);
})();
</script>
</body><grammarly-desktop-integration data-grammarly-shadow-root="true"></grammarly-desktop-integration></html>