summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Hofmaier2018-12-08 15:55:49 +0100
committerChristian Hofmaier2018-12-08 15:55:49 +0100
commit902b299392b894fa6183c9bd2039bba114813e7e (patch)
tree27d51b9b9fb2b269612b34f6a2ead4e476a64821
parent[locationinfo] fix panel being closed all day long in summary (diff)
downloadslx-admin-902b299392b894fa6183c9bd2039bba114813e7e.tar.gz
slx-admin-902b299392b894fa6183c9bd2039bba114813e7e.tar.xz
slx-admin-902b299392b894fa6183c9bd2039bba114813e7e.zip
[locationinfo] fix header not detecting events in only room mode
- fix redundant initialize when only calendar mode
-rwxr-xr-xmodules-available/locationinfo/templates/frontend-default.html34
1 files changed, 31 insertions, 3 deletions
diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html
index 7317f8e2..cb61d141 100755
--- a/modules-available/locationinfo/templates/frontend-default.html
+++ b/modules-available/locationinfo/templates/frontend-default.html
@@ -621,8 +621,12 @@ optional:
// Manually initialize mode 2, as initRoomLayout isn't called for this mode
if (room.config.mode === 2) {
+ var date = MyDate();
+ var now = date.getTime();
queryCalendars();
queryRooms();
+ lastCalendarUpdate = now;
+ lastRoomUpdate = now;
}
mainUpdateLoop();
setInterval(mainUpdateLoop, 10000);
@@ -960,6 +964,10 @@ optional:
}
}
room.timetable = json;
+ for (var property in room.timetable) {
+ room.timetable[property].start = cleanDate(room.timetable[property].start);
+ room.timetable[property].end = cleanDate(room.timetable[property].end);
+ }
if (room.config.mode !== 3) {
var cal = room.$.calendar;
cal.weekCalendar('option', 'data', {events: json});
@@ -980,6 +988,27 @@ optional:
}
}
+ function cleanDate(d) {
+ if (typeof d === 'string') {
+ // if is numeric
+ if (!isNaN(Number(d))) {
+ return cleanDate(parseInt(d, 10));
+ }
+
+ // this is a human readable date
+ if (d[d.length - 1] !== 'Z') d += 'Z';
+ var o = new Date(d);
+ o.setTime(o.getTime() + (o.getTimezoneOffset() * 60 * 1000));
+ return o;
+ }
+
+ if (typeof d === 'number') {
+ return new Date(d);
+ }
+
+ return d;
+ }
+
/**
* scales calendar, called once on create and on window resize
* @param room Room Object
@@ -1179,11 +1208,10 @@ optional:
function ComputeCurrentState(room) {
if (!IsOpen(MyDate(), room)) {
room.state = {state: "closed", end: GetNextOpening(room), title: "", next: ""};
-
return;
}
- var closing = GetNextClosing(room);
+ var closing = GetNextClosing(room);
var event = getNextEvent(room.timetable);
// no event and no closing
@@ -1604,7 +1632,7 @@ optional:
/**
* Function for translation
- * @param toTranslate key which we wan't to translate
+ * @param toTranslate key which we want to translate
* @returns r translated string
*/
function t(toTranslate) {