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
71 lines (64 loc) · 2.68 KB
/
scripts.js
File metadata and controls
71 lines (64 loc) · 2.68 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
66
67
68
69
70
71
// Write your JavaScript code here.
// Remember to pay attention to page loading!
window.addEventListener("load", function() {
console.log("Window loaded.");
const takeOff = document.getElementById('takeoff');
const landing = document.getElementById("landing");
const missionAbort = document.getElementById("missionAbort");
const shuttleBackground = document.getElementById("shuttleBackground")
const spaceShuttleHeight = document.getElementById("spaceShuttleHeight")
const up = document.getElementById("up");
const down = document.getElementById("down")
const right = document.getElementById("right")
const left = document.getElementById("left")
const rocket = document.getElementById("rocket")
takeOff.addEventListener('click', function(){
let input = window.confirm("Confirm that the shuttle is ready for takeoff.")
if (input) {flightStatus.innerHTML = "Shuttle in flight." ;
shuttleBackground.style.backgroundColor = "blue";
spaceShuttleHeight.innerHTML = "10000";
}
else { flightStatus.innerHTML = "Space shuttle ready for takeoff";
shuttleBackground.style.backgroundColor = ""
};
})
landing.addEventListener('click', function(){
let input = window.confirm("The shuttle is landing. Landing gear engaged")
if (input) {flightStatus.innerHTML = "The shuttle has landed.";
shuttleBackground.style.backgroundColor = "";
}
})
missionAbort.addEventListener('click', function(){
let input = window.confirm("Confirm that you want to abort the mission.")
if (input) {flightStatus.innerHTML = "Mission aborted.";
shuttleBackground.style.backgroundColor = "";
spaceShuttleHeight.innerHTML = "0"
}
})
up.addEventListener('click', function(){
let movement= parseInt(spaceShuttleHeight.innerHTML);
spaceShuttleHeight.innerHTML = (movement + movement)
})
down.addEventListener('click', function(){
let movement= parseInt(spaceShuttleHeight.innerHTML);
let tenK = "10000"
let tenkDown = parseInt(tenK)
spaceShuttleHeight.innerHTML = (movement - tenkDown)
})
left.addEventListener('click', function(){
parseInt(rocket.style.left, 10)
})
/* takeOff.addEventListener('click', function(){
let input = window.confirm("Confirm that the shuttle is ready for takeoff.")
if (input) { shuttleBackground.backgroundColor = "blue" ;
}
else {
shuttleBackground.backgroundColor = "" }
})*/
})
/*takeOff.addEventListener('click', function() {
if ( window.confirm("Confirm that the shuttle is ready for takeoff.")){
flightStatus.innerHTML = "Shuttle in flight";
color = 'blue';
} else {flightStatus.innerHTML = "Space shuttle ready for takeoff" } ;
})*/