forked from LaunchCodeEducation/DOM-and-Events-Studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
45 lines (40 loc) · 2.3 KB
/
scripts.js
File metadata and controls
45 lines (40 loc) · 2.3 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
window.addEventListener("load", function () {
console.log("window loaded");
let takeoff = document.getElementById("takeoff");
takeoff.addEventListener("click",function(){
let takeoffConfimration = window.confirm("Confirm that the shuttle is ready for takeoff");
if (takeoffConfimration = true){
document.getElementById("flightStatus").innerHTML = "Shuttle in Flight";
document.getElementById("shuttleBackground").style.backgroundColor = "blue";
document.getElementById("spaceShuttleHeight").innerHTML = Number(document.getElementById("spaceShuttleHeight").innerHTML) + 10000;
}
});
let landing = this.document.getElementById("landing");
landing.addEventListener("click",function(){
window.alert("The shuttle is landing. Landing gear engaged.");
document.getElementById("flightStatus").innerHTML = "The shuttle has landed.";
document.getElementById("shuttleBackground").style.backgroundColor = "green";
document.getElementById("spaceShuttleHeight").innerHTML = 0;
});
let missionAbort = document.getElementById("missionAbort");
missionAbort.addEventListener("click",function(){
let missionAbortConfimration = window.confirm("Confirm that you want to abort the mission.");
if (missionAbortConfimration = true){
document.getElementById("flightStatus").innerHTML = "Mission aborted.";
document.getElementById("shuttleBackground").style.backgroundColor = "green";
document.getElementById("spaceShuttleHeight").innerHTML = 0;
}
});
let up = document.getElementById("up");
up.addEventListener("click", function(){
document.getElementById("spaceShuttleHeight").innerHTML = Number(document.getElementById("spaceShuttleHeight").innerHTML) + 10000;
let rocket = document.getElementById("rocket");
rocket.style.top = Number(rocket.style.top) - 10 + "px";
});
let down = document.getElementById("down");
down.addEventListener("click", function(){
document.getElementById("spaceShuttleHeight").innerHTML = Number(document.getElementById("spaceShuttleHeight").innerHTML) - 10000;
let rocket = document.getElementById("rocket");
rocket.style.top = Number(rocket.style.top) + 10 + "px";
});
});