Commit 44d9e905 authored by Muhammad Ameen's avatar Muhammad Ameen 💻

issue fix

parent fc7bfc24
......@@ -22,7 +22,9 @@
</div>
<div class="floorBox">
<div class="lift" id="liftBox"></div>
<div class="lift" id="liftBox">
</div>
</div>
</div>
......
......@@ -10,42 +10,47 @@ let btn0 = document.getElementById("btn0"),
function command(floorNo) {
let checkNumber = floorArr.includes(floorNo);
if (checkNumber === false) {
if (checkNumber === false && currentFloor !== floorNo) {
floorArr.push(floorNo);
floorsArrP.innerHTML = floorArr;
}
if (floorArr.length === 1) {
move();
}
switch (floorNo) {
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;
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) {
liftBox.style.marginTop = "680px";
liftBox.style.transition = "5s";
currentFloor = 0;
setTimeout(() => {
if (floorArr.length !== 0) {
floorArr.splice(0, 1);
......@@ -57,7 +62,7 @@ function move() {
} else if (floorArr[0] === 1) {
liftBox.style.marginTop = "544px";
liftBox.style.transition = "5s";
currentFloor = 1;
setTimeout(() => {
if (floorArr.length !== 0) {
floorArr.splice(0, 1);
......@@ -69,7 +74,7 @@ function move() {
} else if (floorArr[0] === 2) {
liftBox.style.marginTop = "408px";
liftBox.style.transition = "5s";
currentFloor = 2;
setTimeout(() => {
if (floorArr.length !== 0) {
floorArr.splice(0, 1);
......@@ -81,6 +86,7 @@ function move() {
} else if (floorArr[0] === 3) {
liftBox.style.marginTop = "272px";
liftBox.style.transition = "5s";
currentFloor = 3;
setTimeout(() => {
if (floorArr.length !== 0) {
floorArr.splice(0, 1);
......@@ -92,6 +98,7 @@ function move() {
} else if (floorArr[0] === 4) {
liftBox.style.marginTop = "136px";
liftBox.style.transition = "5s";
currentFloor = 4;
setTimeout(() => {
if (floorArr.length !== 0) {
floorArr.splice(0, 1);
......
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