summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/templates/frontend-summary.html
diff options
context:
space:
mode:
authorSimon Rettberg2017-12-05 14:27:43 +0100
committerSimon Rettberg2017-12-05 14:27:43 +0100
commit0e15c641b55e4dc03634c5fd3a1227aa06e4d7f1 (patch)
tree961e7fad726318a588e150be6f80fec39b4a6bae /modules-available/locationinfo/templates/frontend-summary.html
parent[statistics] Fix link to runmode in client details view (diff)
downloadslx-admin-0e15c641b55e4dc03634c5fd3a1227aa06e4d7f1.tar.gz
slx-admin-0e15c641b55e4dc03634c5fd3a1227aa06e4d7f1.tar.xz
slx-admin-0e15c641b55e4dc03634c5fd3a1227aa06e4d7f1.zip
[locationinfo] Fix timezone offset on QWebView in summary panel
Copy cleanDate function from weekcalendar
Diffstat (limited to 'modules-available/locationinfo/templates/frontend-summary.html')
-rw-r--r--modules-available/locationinfo/templates/frontend-summary.html55
1 files changed, 40 insertions, 15 deletions
diff --git a/modules-available/locationinfo/templates/frontend-summary.html b/modules-available/locationinfo/templates/frontend-summary.html
index 084f6671..9644c860 100644
--- a/modules-available/locationinfo/templates/frontend-summary.html
+++ b/modules-available/locationinfo/templates/frontend-summary.html
@@ -117,21 +117,25 @@
var config = {{{config}}};
$(document).ready(function () {
- // TODO: As in default panel, use time from json
- SetUpDate(new Date());
init();
});
function init() {
- // var ids = getUrlParameter("id");
-
- /*
- $.getJSON("../../../api.php?do=locationinfo&action=locationtree&id=" + ids, function (result) {
- generateLayout(result);
-
- setTimeout(update, 1000);
- });
- */
+ var time = false;
+ if (config.time) {
+ var p = config.time.split('-');
+ if (p.length === 6) {
+ time = new Date(p[0], (p[1] - 1), p[2], p[3], p[4], p[5]);
+ console.log(time);
+ }
+ if (time === false || isNaN(time.getTime()) || time.getFullYear() < 2010) {
+ time = new Date(config.time);
+ }
+ if (!time || isNaN(time.getTime()) || time.getFullYear() < 2010) {
+ time = new Date();
+ }
+ }
+ SetUpDate(time);
generateLayout(config.tree);
update();
}
@@ -195,8 +199,9 @@
var rommUpdateIds = "";
var count = 0;
var nextUpdate = 15000;
+ var property;
// TODO: Only query a few rooms is not possible with the new api stuff ...
- for (var property in rooms) {
+ for (property in rooms) {
if (rooms[property].lastCalendarUpdate === null || rooms[property].lastCalendarUpdate + CALUPDATE_MS < MyDate().getTime()) {
// TODO: NOT NECESSARY ANYMORE?!
calendarUpdateIds = addIdToUpdateList(calendarUpdateIds, rooms[property].id);
@@ -219,12 +224,32 @@
queryRooms();
nextUpdate = 1000;
}
- for (var property in rooms) {
+ for (property in rooms) {
upDateRoomState(rooms[property]);
}
setTimeout(update, nextUpdate);
}
+ 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;
+ }
function UpdateTimeTables(json) {
var l = json.length;
@@ -234,8 +259,8 @@
}
rooms[json[i].id].timetable = json[i].calendar;
for (var property in rooms[json[i].id].timetable) {
- rooms[json[i].id].timetable[property].start = new Date(rooms[json[i].id].timetable[property].start);
- rooms[json[i].id].timetable[property].end = new Date(rooms[json[i].id].timetable[property].end);
+ rooms[json[i].id].timetable[property].start = cleanDate(rooms[json[i].id].timetable[property].start);
+ rooms[json[i].id].timetable[property].end = cleanDate(rooms[json[i].id].timetable[property].end);
}
ComputeCurrentState(rooms[json[i].id]);
}