Skip to content

modified js file #24

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

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
80 changes: 80 additions & 0 deletions scripts.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,82 @@
// Write your JavaScript code here.
// Remember to pay attention to page loading!
function init() {

let takeOffButton = document.getElementById("takeoff");
let landButton = document.getElementById("landing");
let status=document.getElementById("flightStatus");
let missionAbortButton=document.getElementById("missionAbort");
let up =document.getElementById("up");
let down = document.getElementById("down");
let right = document.getElementById("right");
let left = document.getElementById("left");
let shuttleHeight=document.getElementById("spaceShuttleHeight")
let imgObj=document.getElementById("rocket");


imgObj.style.position = 'absolute';
imgObj.style.bottom='0px';
imgObj.style.left='0px';


takeOffButton.addEventListener('click',function(event){
let response = window.confirm("Is the shuttle ready for takeoff");
if(response){
status.innerHTML= "Shuttle in flight.";
document.getElementById("shuttleBackground").style.backgroundColor = 'blue';
//spaceShuttleHeight
parseIntdocument.getElementById("spaceShuttleHeight").innerHTML=10000;


}
})

landButton.addEventListener('click',function(event){
window.alert("The shuttle is landing. Landing gear engaged");
status.innerHTML= "The shuttle has landed";
document.getElementById("shuttleBackground").style.backgroundColor = 'green';
document.getElementById("spaceShuttleHeight").innerHTML=0;
imgObj.style.position = 'absolute';
imgObj.style.bottom='0px';
imgObj.style.left='0px';
})

missionAbortButton.addEventListener('click',function(event){

let response = window.confirm("Confirm that you want to abort the mission.");
if(response){

status.innerHTML= "Mission aborted";
document.getElementById("shuttleBackground").style.backgroundColor = 'green';
//spaceShuttleHeight
document.getElementById("spaceShuttleHeight").innerHTML=0;
imgObj.style.position = 'absolute';
imgObj.style.bottom='0px';
imgObj.style.left='0px';

}
})
up.addEventListener('click',function(event){

let movement =parseInt(imgObj.style.bottom) + 10 + 'px';
imgObj.style.bottom = movement;
shuttleHeight.innerHTML= pareInt(shuttleHeight.innerHTML) + 10000;

})
down.addEventListener('click',function(){
let movement =parseInt(imgObj.style.bottom) - 10 + 'px';
imgObj.style.bottom = movement;
shuttleHeight.innerHTML= pareInt(shuttleHeight.innerHTML) - 10000;
})
right.addEventListener('click',function(){
let movement =parseInt(imgObj.style.left) + 10 + 'px';
imgObj.style.left = movement;

})
left.addEventListener('click',function(){
let movement =parseInt(imgObj.style.left) - 10 + 'px';
imgObj.style.left = movement;
})
}

window.addEventListener("load", init);