Consistent formatting
Signed-off-by: Joey <bevilacquajoey@gmail.com>
This commit is contained in:
parent
82f824ee0e
commit
ad768bb389
3 changed files with 66 additions and 66 deletions
80
app.js
80
app.js
|
@ -8,49 +8,49 @@ const NOW = new Date();
|
||||||
const timeTable = {};
|
const timeTable = {};
|
||||||
|
|
||||||
function roomStatus(room, callback) {
|
function roomStatus(room, callback) {
|
||||||
return new Promise((resolve, _) => {
|
return new Promise((resolve, _) => {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.addEventListener('load', () => {
|
xhr.addEventListener('load', () => {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const doc = parser.parseFromString(xhr.responseText, 'text/html');
|
const doc = parser.parseFromString(xhr.responseText, 'text/html');
|
||||||
const lessons =
|
const lessons = doc.querySelectorAll(
|
||||||
doc.querySelectorAll('table.rsContentTable div.rsAptSimple');
|
'table.rsContentTable div.rsAptSimple');
|
||||||
const parsed = [];
|
const parsed = [];
|
||||||
|
|
||||||
for (let lesson of lessons) {
|
for (let lesson of lessons) {
|
||||||
const time = lesson.querySelector('span[id$=lblOrario]');
|
const time = lesson.querySelector('span[id$=lblOrario]');
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
start.setHours(parseInt(time.innerText.substring(1,3)));
|
start.setHours(parseInt(time.innerText.substring(1,3)));
|
||||||
start.setMinutes(parseInt(time.innerText.substring(4,6)));
|
start.setMinutes(parseInt(time.innerText.substring(4,6)));
|
||||||
start.setSeconds(0);
|
start.setSeconds(0);
|
||||||
|
|
||||||
const end = new Date();
|
const end = new Date();
|
||||||
end.setHours(parseInt(time.innerText.substring(7,9)));
|
end.setHours(parseInt(time.innerText.substring(7,9)));
|
||||||
end.setMinutes(parseInt(time.innerText.substring(10,12)));
|
end.setMinutes(parseInt(time.innerText.substring(10,12)));
|
||||||
end.setSeconds(0);
|
end.setSeconds(0);
|
||||||
|
|
||||||
parsed.push({
|
parsed.push({
|
||||||
title: lesson.getAttribute('title'),
|
title: lesson.getAttribute('title'),
|
||||||
start: start,
|
start: start,
|
||||||
end: end
|
end: end
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(parsed);
|
||||||
});
|
});
|
||||||
}
|
xhr.open('GET', URL + room);
|
||||||
|
xhr.send();
|
||||||
resolve(parsed);
|
|
||||||
});
|
});
|
||||||
xhr.open('GET', URL + room);
|
|
||||||
xhr.send();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ROOMS = [
|
const ROOMS = [
|
||||||
'SI-003',
|
'SI-003',
|
||||||
'SI-015',
|
'SI-015',
|
||||||
'SI-004',
|
'SI-004',
|
||||||
'SI-006',
|
'SI-006',
|
||||||
'SI-013',
|
'SI-013',
|
||||||
'SI-007',
|
'SI-007',
|
||||||
'SI-008',
|
'SI-008',
|
||||||
];
|
];
|
||||||
|
|
||||||
const ROOM_LIST = document.querySelector(".times");
|
const ROOM_LIST = document.querySelector(".times");
|
||||||
|
@ -152,10 +152,10 @@ function setupTimeMachine() {
|
||||||
setTimePreview(new Date(NOW.getTime() + 600000));
|
setTimePreview(new Date(NOW.getTime() + 600000));
|
||||||
}
|
}
|
||||||
|
|
||||||
(async function() {
|
(async () => {
|
||||||
for (const room of ROOMS) {
|
for (const room of ROOMS) {
|
||||||
await buildRoomMarkup(room);
|
await buildRoomMarkup(room);
|
||||||
}
|
}
|
||||||
})()
|
})();
|
||||||
|
|
||||||
setupTimeMachine();
|
setupTimeMachine();
|
||||||
|
|
14
index.html
14
index.html
|
@ -74,19 +74,19 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<template id="room">
|
<template id="room">
|
||||||
<h2 class="room-title"></h2>
|
<h2 class="room-title"></h2>
|
||||||
<ul class="list"></ul>
|
<ul class="list"></ul>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="time-free">
|
<template id="time-free">
|
||||||
<li><strong>Free all day</strong></li>
|
<li><strong>Free all day</strong></li>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="time-slot">
|
<template id="time-slot">
|
||||||
<li>
|
<li>
|
||||||
<span class="title"></span>
|
<span class="title"></span>
|
||||||
(<span class="start"></span>-<span class="end"></span>)
|
(<span class="start"></span>-<span class="end"></span>)
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
{
|
{
|
||||||
"short_name": "USI Rooms",
|
"short_name": "USI Rooms",
|
||||||
"name": "USI INF Rooms",
|
"name": "USI INF Rooms",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "./assets/images/icon-192.png",
|
"src": "./assets/images/icon-192.png",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"sizes": "192x192"
|
"sizes": "192x192"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "./assets/images/icon-512.png",
|
"src": "./assets/images/icon-512.png",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"sizes": "512x512"
|
"sizes": "512x512"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"start_url": "./index.html",
|
"start_url": "./index.html",
|
||||||
"background_color": "#fafafa",
|
"background_color": "#fafafa",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"scope": "./",
|
"scope": "./",
|
||||||
"theme_color": "#333333"
|
"theme_color": "#333333"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue