Commit 7b635827 authored by Roman Regouin's avatar Roman Regouin
Browse files

Merge Graphics Functions Into UI_CSS_2ndVersion

parents cad11800 33f2ab34
......@@ -30,7 +30,6 @@
#sketchTable tr td:nth-child(4) {
background-color: pink;
width: 15%;
}
#sketchTable tr td {
......@@ -57,26 +56,28 @@
.cabin {
max-width: 11.1vh !important;;
}
/* Cabin Buttons */
.sideContainerLeft {
width: 10%;
max-height: 60%;
position: absolute;
max-height: 60%;
width: 10%;
left: 0;
top: 20vh;
}
.sideContainerRight {
width: 10%;
max-height: 60%;
position: absolute;
right: 0;
top: 20vh;
}
.sideContainer img {
max-width: 5vw;
margin: 5px;
}
.userSide {
max-width: 100% !important;
width: 16%;
}
\ No newline at end of file
......@@ -72,9 +72,12 @@ function addFloor(cabinIsHere, floorNumber, doorState) {
floorCell.innerText = floorNumber;
let containerUserSide = document.createElement('td');
let bpImage = document.createElement('img');
bpImage.classList.add("userSide");
addImage(bpImage, "BpOFF", "pressButton", "png", "imagePressButtonFloor" + floorNumber);
let indicatorImage = document.createElement('img');
indicatorImage.classList.add("userSide");
addImage(indicatorImage, "IndicatorOFF","Indicator of the press button", "png","indicatorBP" + floorNumber);
containerUserSide.appendChild(bpImage);
containerUserSide.appendChild(indicatorImage);
......@@ -86,16 +89,14 @@ function addFloor(cabinIsHere, floorNumber, doorState) {
function moveCabinToFloor(floor, bis) {
let newFloor;
let currentFloor;
if (cabin.bis) {
if (cabin.bis)
currentFloor = document.getElementById('imageCabinFloor' + cabin.floor + "Bis");
} else {
else
currentFloor = document.getElementById('imageCabinFloor' + cabin.floor);
}
if (bis) {
if (bis)
newFloor = document.getElementById("imageCabinFloor" + floor + "Bis");
} else {
else
newFloor = document.getElementById("imageCabinFloor" + floor);
}
addImage(currentFloor,"CabinNONE","empty image size cabin","png", "");
addImage(newFloor,"Cabin","cabin image","png","");
cabin.floor = floor;
......
window.addEventListener('load', function () {
initLastData();
});
const maxBit = 11; // the higher bit that we need (going from 0 to 11)
const nbFloor = 5; // going from 0 to nbFloor-1
let lastData = {
floor0: {},
floor1: {},
floor2: {},
floor3: {},
floor4: {},
};
function initLastData() {
for (let k = 0; k < nbFloor; k++)
for (let i = 0; i < maxBit; i++) {
lastData["floor" + k][i] = 0;
}
}
function changeIndicator(floor, currentState, lastState, id) {
let src = null;
let indicator = document.getElementById(id + floor);
if (currentState!=lastState) {
if (currentState == 1)
src = "IndicatorON";
else
src = "indicatorOFF";
}
addImage(indicator, src, indicator.alt + floor, "jpg", indicator.id);
}
function changeButton(floor, currentState, lastState, id) {
let src = null;
let button = document.getElementById(id + floor);
if (currentState!=lastState) {
if (currentState == 1)
src = "BpON";
else
src = "BpOFF";
}
addImage(button, src, button.alt + floor, "png", button.id);
}
/* OutPut Functions */
function sensorFloor(floor, currentState, lastState) {
changeIndicator(floor, currentState, lastState, "indicatorF" + floor);
moveCabinToFloor(floor,false);
}
function upSensorFloor(floor, currentState, lastState) {
changeIndicator(floor, currentState, lastState, "indicatorUF" + floor);
}
function downSensorFloor(floor, currentState, lastState) {
changeIndicator(floor, currentState, lastState, "indicatorDF" + floor);
}
function openDoors(floor, currentState, lastState) {
let door = document.getElementById("imageDoor" + floor);
addImage(door, "DoorOPEN", door.alt + floor, "png", door.id);
}
function closeDoors(floor, currentState, lastState) {
let door = document.getElementById("imageDoor" + floor);
addImage(door, "DoorCLOSE", door.alt + floor, "png", door.id);
}
function buttonFloor(floor, currentState, lastState) {
changeButton(floor,currentState,lastState,"imagePressButtonFloor" + floor);
}
function cabinButtonFloor(floor, currentState, lastState) {
changeButton(floor, currentState, lastState, "buttonCabin" + floor);
}
/* Input functions */
function indicatorCall(floor, currentState, lastState) {
changeIndicator(floor, currentState, lastState, "drcIndicator" + floor);
}
function doorOpeningDirection(floor, currentState, lastState) {
let direction = document.getElementById("imageDirection" + floor);
if (currentState==1)
addImage(direction, "OPEN", direction.alt + floor, "png", direction.id);
else
addImage(direction, "CLOSE", direction.alt + floor, "png", direction.id);
}
function doorMoving(floor, currentState, lastState) {}
function indicatorFloor(floor, currentState, lastState) {
changeIndicator(floor, currentState, lastState, "imagePressButtonFloor" + floor);
}
\ No newline at end of file
Supports Markdown
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