summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorSimon Rettberg2017-07-07 12:57:43 +0200
committerSimon Rettberg2017-07-07 12:57:43 +0200
commitae0e095995048d717e9b1d4515b36c8f861ec5eb (patch)
treeaf4b2615a8026a7235de7dad9d627c3cb4cd8207 /modules-available
parent[syslog] Improved filtering with suggestions from existing log (diff)
downloadslx-admin-ae0e095995048d717e9b1d4515b36c8f861ec5eb.tar.gz
slx-admin-ae0e095995048d717e9b1d4515b36c8f861ec5eb.tar.xz
slx-admin-ae0e095995048d717e9b1d4515b36c8f861ec5eb.zip
[locationinfo] Try working around messy time handling (timezones etc), CSS
Webkit/Presto and Blink/Gecko (or rather the corresponding JS engine) disagree about how to handle certain date format strings wrt. time zones. This leads to nasty discrepancies of events being displayed in the calendar. (Unfortunately the students working on this project could not be convinced that properly handling time zones when dealing with time information should be considered important.) Also, some tweaks to CSS/layout have been implemented so the design isn't as messed up on old webkits that don't support flex layout.
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/locationinfo/api.inc.php2
-rwxr-xr-xmodules-available/locationinfo/frontend/doorsign.html29
-rwxr-xr-xmodules-available/locationinfo/frontend/jquery-week-calendar/jquery.weekcalendar.js17
-rw-r--r--modules-available/locationinfo/inc/coursebackend.inc.php2
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php4
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php33
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php4
7 files changed, 66 insertions, 25 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index 767066f3..05af4111 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -257,7 +257,7 @@ function getConfig($paneluuid)
$config['ts'] = (int)$panel['lastchange'];
$config['locations'] = array_values($config['locations']);
- $config['time'] = date('Y-m-d H:i:s');
+ $config['time'] = date('Y-n-j-G-') . (int)date('i') . '-' . (int)(date('s'));
return $config;
}
diff --git a/modules-available/locationinfo/frontend/doorsign.html b/modules-available/locationinfo/frontend/doorsign.html
index 97504284..8acdb07b 100755
--- a/modules-available/locationinfo/frontend/doorsign.html
+++ b/modules-available/locationinfo/frontend/doorsign.html
@@ -58,6 +58,14 @@ optional:
justify-content: space-between;
}
+ .pull-left {
+ float: left;
+ }
+
+ .clearfix {
+ clear: both;
+ }
+
.col {
padding: 0 4px;
color: white;
@@ -67,6 +75,8 @@ optional:
}
.col-square {
+ order: 1000;
+ float: right;
width: 46pt;
width: 4vw;
height: 46pt;
@@ -147,6 +157,7 @@ optional:
.center {
text-align: center;
+ margin: auto;
}
.room-layout {
@@ -439,7 +450,15 @@ optional:
return;
}
- var time = new Date(result.time);
+ var time = false;
+ var p = result.time.split('-');
+ if (p.length === 6) {
+ time = new Date(p[0], p[1], p[2], p[3], p[4], p[5]);
+ console.log(time);
+ }
+ if (time === false || isNaN(time.getTime()) || time.getYear() < 2010) {
+ time = new Date(result.time);
+ }
if (isNaN(time.getTime()) || time.getYear() < 2010) {
time = new Date();
}
@@ -587,7 +606,7 @@ optional:
$("body").append($loc);
room.$.container = $loc;
- room.$.locationName = $('<div>').addClass('col').addClass('header-font');
+ room.$.locationName = $('<div>').addClass('col').addClass('header-font').addClass('pull-left');
room.$.currentEvent = $("<span>").addClass('nowrap');
room.$.currentRemain = $("<span>").addClass('nowrap').addClass('timer');
room.$.seatsCounter = $('<span>').addClass('seats-counter');
@@ -595,10 +614,11 @@ optional:
var $header = $('<div>').addClass('row').addClass('count-' + roomIds.length);
$header.append(room.$.locationName);
- $header.append($('<div>').addClass('col header-font center').append(room.$.currentEvent).append(' ').append(room.$.currentRemain));
$header.append(room.$.seatsBackground);
+ $header.append($('<div>').addClass('col header-font center').append(room.$.currentEvent).append(' ').append(room.$.currentRemain));
room.$.header = $header;
$loc.append($header);
+ $header.append('<div class="clearfix">');
if (room.name !== null) {
room.$.locationName.text(room.name);
@@ -941,6 +961,9 @@ optional:
console.log("Error: Calendar data was empty or malformed.");
return;
}
+ if (json.length === 0) {
+ console.log("Notice: Calendar already empty from server");
+ }
var now = MyDate().getTime();
json = json.filter(function (el) {
if (!el.title || !el.start || !el.end) return false;
diff --git a/modules-available/locationinfo/frontend/jquery-week-calendar/jquery.weekcalendar.js b/modules-available/locationinfo/frontend/jquery-week-calendar/jquery.weekcalendar.js
index 63ea1ecd..e84b9057 100755
--- a/modules-available/locationinfo/frontend/jquery-week-calendar/jquery.weekcalendar.js
+++ b/modules-available/locationinfo/frontend/jquery-week-calendar/jquery.weekcalendar.js
@@ -43,7 +43,7 @@ function MyDate() {
return {
options: {
- date: MyDate(),
+ date: MyDate,
timeFormat: null,
dateFormat: 'M d, Y',
alwaysDisplayTimeMinutes: true,
@@ -1441,6 +1441,7 @@ function MyDate() {
$.each(eventsToRender, function(i, calEvent) {
// render a multi day event as various event :
// thanks to http://github.com/fbeauchamp/jquery-week-calendar
+ if (!calEvent || !calEvent.start || !calEvent.end) return;
var initialStart = new Date(calEvent.start);
var initialEnd = new Date(calEvent.end);
var maxHour = self.options.businessHours.limitDisplay ? self.options.businessHours.end : 24;
@@ -2023,9 +2024,6 @@ function MyDate() {
* Clean specific event
*/
_cleanEvent: function(event) {
- if (event.date) {
- event.start = event.date;
- }
event.start = this._cleanDate(event.start);
event.end = this._cleanDate(event.end);
if (!event.end) {
@@ -2205,10 +2203,13 @@ function MyDate() {
}
// this is a human readable date
- return Date.parse(d) || new Date(d);
+ 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') {
+ if (typeof d === 'number') {
return new Date(d);
}
@@ -2223,12 +2224,12 @@ function MyDate() {
var returnStr = '';
for (var i = 0; i < format.length; i++) {
var curChar = format.charAt(i);
- if (i != 0 && format.charAt(i - 1) == '\\') {
+ if (i !== 0 && format.charAt(i - 1) === '\\') {
returnStr += curChar;
}
else if (this._replaceChars[curChar]) {
returnStr += this._replaceChars[curChar](date, this);
- } else if (curChar != '\\') {
+ } else if (curChar !== '\\') {
returnStr += curChar;
}
}
diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php
index 447a5598..b47fc2c6 100644
--- a/modules-available/locationinfo/inc/coursebackend.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend.inc.php
@@ -179,7 +179,9 @@ abstract class CourseBackend
$remoteIds[$row['locationid']] = $row['serverlocationid'];
}
}
+ error_log('Fetching ' . $this->serverId);
$backendResponse = $this->fetchSchedulesInternal($remoteIds);
+ error_log('Reply: ' . print_r($backendResponse, true));
if ($backendResponse === false) {
return false;
}
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
index a9756dda..4c2dde6c 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
@@ -122,8 +122,8 @@ class CourseBackend_Davinci extends CourseBackend
$subject = isset($lesson['Subject']) ? $lesson['Subject'] : '???';
$timetable[] = array(
'title' => $subject,
- 'start' => $date . " " . $start . ':00',
- 'end' => $date . " " . $end . ':00'
+ 'start' => $date . "T" . $start . ':00',
+ 'end' => $date . "T" . $end . ':00'
);
}
$schedules[$roomId] = $timetable;
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
index 0e5d654e..e2577284 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
@@ -94,17 +94,32 @@ class CourseBackend_Dummy extends CourseBackend
{
$a = array();
foreach ($roomId as $id) {
- $x['id'] = $id;
- $calendar['title'] = "test exam";
- $calendar['start'] = "2017-3-08 13:00:00";
- $calendar['end'] = "2017-3-08 16:00:00";
- $calarray = array();
- $calarray[] = $calendar;
- $x['calendar'] = $calarray;
- $a[$id] = $calarray;
+ $x = array();
+ $time = strtotime('today');
+ $end = strtotime('+7 days', $time);
+ srand(crc32($id) ^ $time);
+ $last = $time;
+ do {
+ do {
+ $time += rand(4, 10) * 900;
+ $h = date('G', $time);
+ } while ($h < 7 || $h > 19);
+ $today = strtotime('today', $time);
+ if ($today !== $last) {
+ srand(crc32($id) ^ $today);
+ $last = $today;
+ }
+ $dur = rand(2,6) * 1800;
+ $x[] = array(
+ 'title' => 'Test ' . rand(1000,9999),
+ 'start' => date('Y-m-d\TH:i:s', $time),
+ 'end' => date('Y-m-d\TH:i:s', $time + $dur),
+ );
+ $time += $dur;
+ } while ($time < $end);
+ $a[$id] = $x;
}
-
return $a;
}
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
index 65f52e6b..ef262522 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
@@ -283,8 +283,8 @@ class CourseBackend_HisInOne extends CourseBackend
$endTime = $this->getArrayPath($plannedDate, '/hisendtime')[0];
$tTables[$eventRoomId][] = array(
'title' => $name[0],
- 'start' => $eventDate . " " . $startTime,
- 'end' => $eventDate . " " . $endTime
+ 'start' => $eventDate . "T" . $startTime,
+ 'end' => $eventDate . "T" . $endTime
);
}
}