init
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<script src="/iframe_api.js"></script>
|
||||
<link href="./css/nes.min.css" type="text/css" rel="stylesheet" />
|
||||
<style>
|
||||
body {
|
||||
padding: 15px;
|
||||
background-color:#212529;
|
||||
}
|
||||
|
||||
#panel {
|
||||
margin: 15px auto;
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
#panel p {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
#buttons {
|
||||
margin: 15px auto;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
#buttons-rooms {
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
#buttons-rooms>a {
|
||||
flex-basis: 100%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
#buttons-controls {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="buttons" class="nes-container">
|
||||
<div id="buttons-rooms">
|
||||
|
||||
</div>
|
||||
<div id="buttons-controls">
|
||||
<a class="nes-btn">↔️</a>
|
||||
<a class="nes-btn">↕️</a>
|
||||
<a class="nes-btn is-error">🔔</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="panel" class="nes-container is-dark with-title is-centered">
|
||||
<p class="title">Elevator</p>
|
||||
<p>In case of emergency please press and hold the alarm button for 5 seconds.</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let rooms = [
|
||||
{
|
||||
'room': 'clubhaus_downstairs.json',
|
||||
'name': 'downstairs'
|
||||
}, {
|
||||
'room': 'clubhaus.json',
|
||||
'name': 'main floor'
|
||||
}, {
|
||||
'room': 'clubhaus_upstairs.json',
|
||||
'name': 'first floor'
|
||||
}, {
|
||||
'room': 'clubhaus_roof.json',
|
||||
'name': 'roof'
|
||||
}
|
||||
];
|
||||
|
||||
let firstIndex = -1;
|
||||
|
||||
let buttons = document.getElementById("buttons-rooms");
|
||||
|
||||
WA.onInit().then(() => {
|
||||
let roomId = WA.room.id;
|
||||
let currentIndex = -1;
|
||||
for (let i = 0; i < rooms.length; i++) {
|
||||
let room = rooms[i];
|
||||
let index = i + firstIndex;
|
||||
let button = document.createElement("a");
|
||||
button.id = i;
|
||||
button.classList.add("nes-btn");
|
||||
button.innerHTML = index + " " + room.name;
|
||||
buttons.appendChild(button);
|
||||
|
||||
if (roomId.endsWith(room.room)) {
|
||||
button.disabled = true;
|
||||
button.classList.add('is-disabled');
|
||||
currentIndex = i;
|
||||
}
|
||||
|
||||
button.addEventListener('click', function (event) {
|
||||
let button = event.target;
|
||||
if (!button.disabled) {
|
||||
let index = button.id;
|
||||
let room = rooms[index];
|
||||
let diff = index - currentIndex;
|
||||
if (currentIndex > index) {
|
||||
diff = currentIndex - index;
|
||||
}
|
||||
|
||||
|
||||
for (let i = 0; i < rooms.length; i++) {
|
||||
let b = document.getElementById(i);
|
||||
b.disabled = true;
|
||||
b.classList.add('is-disabled');
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
WA.nav.goToRoom(room.room + '#start_elevator');
|
||||
}, diff * 2000);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user