summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/frontend
diff options
context:
space:
mode:
authorMichael Scherle2017-03-20 19:47:17 +0100
committerMichael Scherle2017-03-20 19:47:17 +0100
commitf451d4ffc6b3b02ccc3ee3ec111b84b3c110e0d9 (patch)
tree01ec59151a9d70c1fc0f930200de158a9c0e8add /modules-available/locationinfo/frontend
parentAPI: Fixed a Bug where every server iteration the result array was initialized. (diff)
downloadslx-admin-f451d4ffc6b3b02ccc3ee3ec111b84b3c110e0d9.tar.gz
slx-admin-f451d4ffc6b3b02ccc3ee3ec111b84b3c110e0d9.tar.xz
slx-admin-f451d4ffc6b3b02ccc3ee3ec111b84b3c110e0d9.zip
frontend: -calendar scrolls to actual time, if space is to small to show full calendar, -changed querymethods to query dependend on each rooms update time
Diffstat (limited to 'modules-available/locationinfo/frontend')
-rwxr-xr-xmodules-available/locationinfo/frontend/doorsign.html113
-rwxr-xr-xmodules-available/locationinfo/frontend/jquery-week-calendar/jquery.weekcalendar.js5
2 files changed, 68 insertions, 50 deletions
diff --git a/modules-available/locationinfo/frontend/doorsign.html b/modules-available/locationinfo/frontend/doorsign.html
index e628b00d..0b50fcfe 100755
--- a/modules-available/locationinfo/frontend/doorsign.html
+++ b/modules-available/locationinfo/frontend/doorsign.html
@@ -277,8 +277,6 @@ optional:
var rooms = {};
var lastSwitchTime;
var roomsToshow = 0;
- var lastRoomUpdateTime;
- var lastCalendarUpdateTime;
var roomIds;
//Todo change these
var CalendarUpdateTime = 60 * 1000;
@@ -336,6 +334,8 @@ optional:
});
// Downloads the config of a room
+
+
function getConfig(id, room) {
$.ajax({
url: "../../../api.php?do=locationinfo&action=config&id=" + id,
@@ -386,6 +386,7 @@ optional:
// gets the Parameter IDs from the Urls
+
function getId() {
roomIds = getUrlParameter("id");
if (roomIds == null) {
@@ -412,6 +413,7 @@ optional:
// gets Additional Parameters from the URL, and from the
// downloaded json.
// also makes sure parameters are in a given range
+
function getParamerter(room) {
var lang;
@@ -515,8 +517,8 @@ optional:
height = "50%";
}
var i = 0;
- for (var property in rooms) {
-
+ for (var t = 0; t < roomIds.length; t++) {
+ var property = roomIds[t];
var text = "<div class='roompadding' id ='roompadding_" + rooms[property].id + "'></div>";
$("body").append(text);
@@ -607,53 +609,48 @@ optional:
}
- // helper function: checks which rooms are in which mode
- function getUpdateIdsforMode(modearray) {
- var roomIdsToUpdate = "";
- for (var property in rooms) {
- if (rooms[property].config.mode in modearray) {
- if (roomIdsToUpdate == "") {
- roomIdsToUpdate = rooms[property].id;
- } else {
- roomIdsToUpdate = roomIdsToUpdate + "," + rooms[property].id;
- }
- }
- }
- return roomIdsToUpdate;
+ function addIdToUpdateList(list,id) {
+ if(list=="") {
+ list += id;
+ } else {
+ list +=(","+ id);
+ }
+ return list;
}
+
// Main Update loop, this loop runs every 1 seconds and calls all
// function which should be called periodically
+ var timeSteps = 0;
function mainUpdateLoop() {
- //todo add config reload
-
-
- //updates calendar
- if (lastCalendarUpdateTime == null || lastCalendarUpdateTime + CalendarUpdateTime < MyDate().getTime()) {
-
- //Todo
- var roomIdsToUpdate = getUpdateIdsforMode([1, 2, 3, 4]);
-
- if (roomIdsToUpdate != "") {
- // Todo update calendars
- queryCalendars(roomIdsToUpdate);
- }
-
- lastCalendarUpdateTime = MyDate().getTime();
- }
+ // check ervery 10 sec if rooms need new calendar data or room data
+ // groups request
+ if(timeSteps > 9) {
+ timeSteps = 0;
+ var calendarUpdateIds ="";
+ var rommUpdateIds="";
+ for (var property in rooms) {
+ if (rooms[property].config.lastCalendarUpdate == null || rooms[property].config.lastCalendarUpdate + rooms[property].config.calupdate *60* 1000 < MyDate().getTime()) {
- // updates Pcs states
- if (lastRoomUpdateTime == null || lastRoomUpdateTime + RoomUpdateTime < MyDate().getTime()) {
+ calendarUpdateIds = addIdToUpdateList(calendarUpdateIds,rooms[property].id);
+ rooms[property].config.lastCalendarUpdate = MyDate().getTime();
+ }
+ if (rooms[property].config.lastRoomUpdate == null || rooms[property].config.lastRoomUpdate + rooms[property].config.roomupdate *1000 < MyDate().getTime()) {
+ rommUpdateIds= addIdToUpdateList(rommUpdateIds,rooms[property].id);
+ rooms[property].config.lastRoomUpdate = MyDate().getTime();
+ }
+ }
- var roomIdsToUpdate = getUpdateIdsforMode([1, 2, 3, 4]);
- if (roomIdsToUpdate != "") {
- queryRooms(roomIdsToUpdate);
- }
- lastRoomUpdateTime = MyDate().getTime();
- }
+ if (calendarUpdateIds != "") {
+ queryCalendars(calendarUpdateIds);
+ }
+ if (rommUpdateIds != "") {
+ queryRooms(rommUpdateIds);
+ }
+ }
// switches calendar and roomlayout in mode 4
@@ -690,6 +687,7 @@ optional:
}
}
date = now;
+ timeSteps++;
}
@@ -709,6 +707,8 @@ optional:
layout: null,
freePcs: 0,
resized: false,
+ lastCalendarUpdate:null,
+ lastRoomUpdate:null,
getState: function () {
if (this.state == null) {
ComputeCurrentState(this);
@@ -735,7 +735,7 @@ optional:
generateCalendarDiv(percent, room);
var $calendar = $("#calendar_" + room.id).weekCalendar({
timeslotsPerHour: 1,
- timeslotHeight: 20,
+ timeslotHeight: 30,
daysToShow: daysToShow,
height: function ($calendar) {
var height = $(window).height();
@@ -761,6 +761,7 @@ optional:
date: MyDate(),
dateFormat: "j.n",
timeFormat: "G:i",
+ scrollToHourMillis:500,
use24Hour: true,
readonly: true,
showHeader: false,
@@ -781,7 +782,11 @@ optional:
// downloads openingTimes for an room
function getOpeningTimes(room) {
$.getJSON("../../../api.php?do=locationinfo&action=openingtime&id=" + room.id, function (result) {
- SetOpeningTimes(result[0].openingtime, room);
+ if(Object.prototype.toString.call( result ) === '[object Array]' ) {
+ if(result.length > 0){
+ SetOpeningTimes(result[0].openingtime, room);
+ }
+ }
scaleCalendar(room);
})
@@ -791,6 +796,8 @@ optional:
})
}
+
+
function generateCalendarDiv(width, room) {
var div = document.createElement("div");
div.id = "calendar_" + room.id;
@@ -943,16 +950,22 @@ optional:
clientHeight -= 22;
}
-
var height = clientHeight / (room.openTimes * cal.weekCalendar("option", "timeslotsPerHour"));
+
+
+
+ if(height < 30){
+ height = 30;
+ }
+
+
cal.weekCalendar("option", "timeslotHeight", height);
- cal.weekCalendar("updateFreeBusy", room.openingTimesCalendar);
- }
- /**
- * @return {string}
- * @return {string}
- */
+ if(room.openingTimesCalendar != null) {
+ cal.weekCalendar("updateFreeBusy", room.openingTimesCalendar);
+ }
+ cal.weekCalendar("resizeCalendar");
+ }
// used for countdown
// computes the time difference between 2 Date objects
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 4015503b..808939f3 100755
--- a/modules-available/locationinfo/frontend/jquery-week-calendar/jquery.weekcalendar.js
+++ b/modules-available/locationinfo/frontend/jquery-week-calendar/jquery.weekcalendar.js
@@ -323,6 +323,9 @@ function MyDate() {
this._loadCalEvents(this.element.data('startDate'));
},
+ resizeCalendar:function(){
+ this._resizeCalendar();
+ },
/*
* Clear all events currently loaded into the calendar
*/
@@ -1266,10 +1269,12 @@ function MyDate() {
* Draws a thin line which indicates the current time.
*/
_drawCurrentHourLine: function() {
+ var self = this;
var d = new MyDate(),
options = this.options,
businessHours = options.businessHours;
+ self._scrollToHour(d.getHours() ,false);
// first, we remove the old hourline if it exists
$('.wc-hourline', this.element).remove();