Commit d47ce20b authored by Muhammad Ameen's avatar Muhammad Ameen 💻

Elevator Complete

parent 55488ffb
// let floorsArrP = document.getElementById("floorsArr");
// let floorArr = [];
// let currentFloor = 4;
// let liftBox = document.getElementById("liftBox");
// let liftInner = document.getElementById("lift-inner");
// let btn0 = document.getElementById("btn0"),
// btn1 = document.getElementById("btn1"),
// btn2 = document.getElementById("btn2"),
// btn3 = document.getElementById("btn3"),
// btn4 = document.getElementById("btn4");
// function command(floorNo) {
// let checkNumber = floorArr.includes(floorNo);
// if (checkNumber === false && currentFloor !== floorNo) {
// floorArr.push(floorNo);
// floorsArrP.innerHTML = floorArr;
// }
// for (var i = 0; i < floorArr.length; i++) {
// if (floorArr[i] !== currentFloor) {
// switch (floorArr[i]) {
// case 0:
// btn0.style.backgroundColor = "red";
// break;
// case 1:
// btn1.style.backgroundColor = "red";
// break;
// case 2:
// btn2.style.backgroundColor = "red";
// console.log("first");
// break;
// case 3:
// btn3.style.backgroundColor = "red";
// break;
// case 4:
// btn4.style.backgroundColor = "red";
// break;
// default:
// break;
// }
// }
// }
// console.log(floorArr);
// if (floorArr.length === 1) {
// move();
// }
// }
// function move() {
// if (floorArr[0] === 0) {
// liftInner.style.backgroundPosition = "left bottom";
// liftBox.style.marginTop = "680px";
// liftBox.style.transition = "5s";
// currentFloor = 0;
// if (floorArr.length !== 0) {
// setTimeout(() => {
// floorArr.splice(0, 1);
// floorsArrP.innerHTML = floorArr;
// btn0.style.backgroundColor = "gray";
// move(floorArr[0]);
// }, 6000);
// setTimeout(() => {
// liftInner.style.backgroundPosition = "right bottom";
// }, 5000);
// }
// } else if (floorArr[0] === 1) {
// liftInner.style.backgroundPosition = "left bottom";
// liftBox.style.marginTop = "544px";
// liftBox.style.transition = "5s";
// currentFloor = 1;
// if (floorArr.length !== 0) {
// setTimeout(() => {
// floorArr.splice(0, 1);
// floorsArrP.innerHTML = floorArr;
// btn1.style.backgroundColor = "gray";
// liftInner.style.backgroundPosition = "right bottom";
// move(floorArr[0]);
// }, 6000);
// setTimeout(() => {
// liftInner.style.backgroundPosition = "right bottom";
// }, 5000);
// }
// } else if (floorArr[0] === 2) {
// liftInner.style.backgroundPosition = "left bottom";
// liftBox.style.marginTop = "408px";
// liftBox.style.transition = "5s";
// currentFloor = 2;
// if (floorArr.length !== 0) {
// setTimeout(() => {
// floorArr.splice(0, 1);
// floorsArrP.innerHTML = floorArr;
// btn2.style.backgroundColor = "gray";
// liftInner.style.backgroundPosition = "right bottom";
// move(floorArr[0]);
// }, 6000);
// setTimeout(() => {
// liftInner.style.backgroundPosition = "right bottom";
// }, 5000);
// }
// } else if (floorArr[0] === 3) {
// liftInner.style.backgroundPosition = "left bottom";
// liftBox.style.marginTop = "272px";
// liftBox.style.transition = "5s";
// currentFloor = 3;
// if (floorArr.length !== 0) {
// setTimeout(() => {
// floorArr.splice(0, 1);
// floorsArrP.innerHTML = floorArr;
// btn3.style.backgroundColor = "gray";
// liftInner.style.backgroundPosition = "right bottom";
// move(floorArr[0]);
// }, 6000);
// setTimeout(() => {
// liftInner.style.backgroundPosition = "right bottom";
// }, 5000);
// }
// } else if (floorArr[0] === 4) {
// liftInner.style.backgroundPosition = "left bottom";
// liftBox.style.marginTop = "0px";
// liftBox.style.transition = "5s";
// currentFloor = 4;
// if (floorArr.length !== 0) {
// setTimeout(() => {
// floorArr.splice(0, 1);
// floorsArrP.innerHTML = floorArr;
// btn4.style.backgroundColor = "gray";
// liftInner.style.backgroundPosition = "right bottom";
// move(floorArr[0]);
// }, 6000);
// setTimeout(() => {
// liftInner.style.backgroundPosition = "right bottom";
// }, 5000);
// }
// }
// }
let floorsArrP = document.getElementById("floorsArr"); let floorsArrP = document.getElementById("floorsArr");
let floorArr = []; let floorArr = [];
let currentFloor = 4; let currentFloor = 4;
...@@ -10,6 +147,16 @@ let btn0 = document.getElementById("btn0"), ...@@ -10,6 +147,16 @@ let btn0 = document.getElementById("btn0"),
btn4 = document.getElementById("btn4"); btn4 = document.getElementById("btn4");
function command(floorNo) { function command(floorNo) {
// let temp = 0;
// for (let i = 0; i < floorArr.length; i++) {
// for (let j = i + 1; j < floorArr.length; j++) {
// if (floorArr[i] > floorArr[j]) {
// temp = floorArr[i];
// floorArr[i] = floorArr[j];
// floorArr[j] = temp;
// }
// }
// }
let checkNumber = floorArr.includes(floorNo); let checkNumber = floorArr.includes(floorNo);
if (checkNumber === false && currentFloor !== floorNo) { if (checkNumber === false && currentFloor !== floorNo) {
floorArr.push(floorNo); floorArr.push(floorNo);
...@@ -117,7 +264,7 @@ function move() { ...@@ -117,7 +264,7 @@ function move() {
} }
} else if (floorArr[0] === 4) { } else if (floorArr[0] === 4) {
liftInner.style.backgroundPosition = "left bottom"; liftInner.style.backgroundPosition = "left bottom";
liftBox.style.marginTop = "136px"; liftBox.style.marginTop = "0px";
liftBox.style.transition = "5s"; liftBox.style.transition = "5s";
currentFloor = 4; currentFloor = 4;
if (floorArr.length !== 0) { if (floorArr.length !== 0) {
...@@ -134,3 +281,13 @@ function move() { ...@@ -134,3 +281,13 @@ function move() {
} }
} }
} }
for (let i = 0; i < floorArr.length; i++) {
for (let j = i + 1; j < floorArr.length; j++) {
if (arr[i] > arr[j]) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
...@@ -19,6 +19,10 @@ body { ...@@ -19,6 +19,10 @@ body {
margin-bottom: 20px; margin-bottom: 20px;
color: white; color: white;
/* font-size: 24px; */ /* font-size: 24px; */
-webkit-box-shadow: 1px 0px 17px -1px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 1px 0px 17px -1px rgba(0, 0, 0, 0.75);
box-shadow: 1px 0px 17px -1px rgba(0, 0, 0, 0.75);
} }
.btn_container { .btn_container {
...@@ -29,7 +33,10 @@ body { ...@@ -29,7 +33,10 @@ body {
} }
.btn:hover { .btn:hover {
background-color: red; background-color: orange;
-webkit-box-shadow: 1px 0px 7px -1px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 1px 0px 7px -1px rgba(0, 0, 0, 0.75);
box-shadow: 1px 0px 7px -1px rgba(0, 0, 0, 0.75);
} }
.floorBox { .floorBox {
...@@ -63,7 +70,7 @@ body { ...@@ -63,7 +70,7 @@ body {
background: linear-gradient(to right, black 50%, white 50%); background: linear-gradient(to right, black 50%, white 50%);
background-size: 200% 100%; background-size: 200% 100%;
background-position: right bottom; background-position: right bottom;
transition: all .5s ease-out; transition: all 0.5s ease-out;
} }
/* .lift:hover { /* .lift:hover {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment