Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scripts.js #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 89 additions & 1 deletion scripts.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,90 @@
// Write your JavaScript code here.
// Remember to pay attention to page loading!
// Remember to pay attention to page loading!


window.addEventListener("load",function(event){
let takeoff=document.getElementById("takeoff");
let status=document.getElementById("flightStatus");
let background=document.getElementById("shuttleBackground");
let shuttleHeight=document.getElementById("spaceShuttleHeight");
let land=document.getElementById("landing");
let abort=document.getElementById("missionAbort");

let down=document.getElementById("down");
let up=document.getElementById("top");
let righ=document.getElementById("right");
let lef=document.getElementById("left");
let pad = document.getElementById("rocket");

takeoff.addEventListener("click",function(event){
let response=window.confirm("Confirm that the shuttle is ready for takeoff");
if(response)
{
status.innerHTML="Shuttle in flight.";
background.style.backgroundColor="blue";
shuttleHeight.innerHTML=10000;
}
})

land.addEventListener("click",function(event){
let response=window.confirm("The shuttle is landing. Landing gear engaged.");
if(response)
{
status.innerHTML="The shuttle has landed.";
background.style.backgroundColor="green";
shuttleHeight.innerHTML=0;
}
})

abort.addEventListener("click",function(event){
let response=window.confirm("Confirm that you want to abort the mission.");
if(response)
{
status.innerHTML="Mission aborted.";
background.style.backgroundColor="green";
shuttleHeight.innerHTML=0;
}
})

down.addEventListener("click",function(event){
let response=window.confirm("Confirm that the shuttle is ready to going down");
if(response)
{
status.innerHTML="Shuttle in flight.";
shuttleHeight.innerHTML=shuttleHeight.innerHTML-10;
}
})

up.addEventListener("click",function(event){
let response=window.confirm("Confirm that the shuttle is ready to going up");
if(response)
{
status.innerHTML="Shuttle in flight.";
shuttleHeight.innerHTML=parseInt (shuttleHeight.innerHTML) + 10;
}
})
window.left = 0;
window.right = 0;
righ.addEventListener("click",function(event){
let response=window.confirm("Confirm that the shuttle is ready to move right");
window.left += 10;
if(response)
{
pad.style.paddingLeft= left + "px";
console.log("padding left");
console.log(window.left);
}
})

lef.addEventListener("click",function(event){
let response=window.confirm("Confirm that the shuttle is ready to move left");
window.right += 10;
if(response)
{
pad.style.paddingRight= right + "px";
console.log("padding right");
console.log(window.right);
}
})

})