summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/frontend/doorsign.html
diff options
context:
space:
mode:
authorMichael Scherle2016-11-26 20:35:01 +0100
committerMichael Scherle2016-11-26 20:35:01 +0100
commit96c7437d5522295edfc95cadd308352e2ffa7a56 (patch)
tree40abdf333fe7fc905af79445b776c455bd6eba21 /modules-available/locationinfo/frontend/doorsign.html
parentFixed a coordination bug which caused rotation bugs. Deleted the locationinfo... (diff)
downloadslx-admin-96c7437d5522295edfc95cadd308352e2ffa7a56.tar.gz
slx-admin-96c7437d5522295edfc95cadd308352e2ffa7a56.tar.xz
slx-admin-96c7437d5522295edfc95cadd308352e2ffa7a56.zip
fixes, support for time over config...
Diffstat (limited to 'modules-available/locationinfo/frontend/doorsign.html')
-rwxr-xr-xmodules-available/locationinfo/frontend/doorsign.html157
1 files changed, 107 insertions, 50 deletions
diff --git a/modules-available/locationinfo/frontend/doorsign.html b/modules-available/locationinfo/frontend/doorsign.html
index 5ca78e6c..c127bb1f 100755
--- a/modules-available/locationinfo/frontend/doorsign.html
+++ b/modules-available/locationinfo/frontend/doorsign.html
@@ -17,7 +17,7 @@ optional:
switchtime:[1-120] sets the time between switchen in mode 4 (in seconds)
calupdate: Time the calender querys for updates,in minutes.
roomupdate: Time the PCs in the room gets updated,in seconds.
- rotation:[0-4] rotation of the roomplan
+ rotation:[0-3] rotation of the roomplan
vertical:[true] only mode 1, sets the calendar above the roomplan
configupdate: Time interval the config gets updated (in minutes)
-->
@@ -30,7 +30,7 @@ optional:
<script type='text/javascript' src='../../js_jqueryui/clientscript.js'></script>
<link rel='stylesheet' type='text/css' href='../../js_jqueryui/style.css'/>
<link rel='stylesheet' type='text/css' href='jquery-week-calendar/jquery.weekcalendar.css'/>
- <script type="text/javascript" src="jquery-week-calendar/libs/date.js"></script>
+
<script type='text/javascript' src="jquery-week-calendar/jquery.weekcalendar.js"></script>
<style type='text/css'>
@@ -70,11 +70,11 @@ optional:
}
.col-1 {
- width: 50%;
+ width: 33%;
}
.col-2 {
- width: 25%;
+ width: 33%;
}
.roomLayoutDesign {
@@ -230,11 +230,13 @@ optional:
}
};
+
$(document).ready(function () {
if (!getId()) {
return;
}
getConfig();
+
});
function getConfig() {
@@ -245,10 +247,21 @@ optional:
timeout: 30000,
success: function (result) {
if (configJson == null) {
+ if(result.room == null) {
+ var heading = $("#courseHeading");
+ heading.text("Error: wrong id");
+ heading.css({'font-size': "30px"});
+ return;
+ }
getParamerter(result);
startMode();
- } else if (JSON.stringify(configJson) != JSON.stringify(result)) {
- location.reload(true);
+ delete result.time;
+ } else{
+ // Todo resync time?
+ delete result.time;
+ if (JSON.stringify(configJson) != JSON.stringify(result)) {
+ location.reload(true);
+ }
}
configJson = result;
setTimeout(function () {
@@ -268,10 +281,11 @@ optional:
$("#courseHeading").text("Error: id required");
return false;
}
+
return true;
}
function getParamerter(json) {
- console.log(json);
+
var lang;
if (json != null) {
mode = parseInt(json.mode);
@@ -288,6 +302,13 @@ optional:
configupdate = parseInt(json.configupdate);
room = json.room;
}
+
+ var time = new Date(time);
+ if (isNaN(time.getTime())) {
+ time = new Date();
+ }
+ SetUpDate(time);
+
if (room != null) {
$("#roomHeader").text(room);
}
@@ -346,11 +367,15 @@ optional:
if (mode == null || isNaN(mode) || mode > 4 || mode < 1) {
mode = 1;
}
+ if(rotation ==null||isNaN(rotation)||rotation < 0 || rotation > 4){
+ rotation = 0;
+ }
if (getUrlParameter("lang") != null && getUrlParameter("lang") in translation) {
lang = getUrlParameter("lang");
}
$('html').attr('lang', lang);
+
}
function startMode() {
@@ -368,10 +393,19 @@ optional:
setInterval(function () {
Update();
}, 1000);
+ queryRoom();
}
// room only
if (mode == 3) {
preInitRoom();
+ $.getJSON("../../../api.php?do=locationinfo&action=openingtime&id=" + roomId, function (result) {
+ SetOpeningTimes(result);
+ queryCalendar();
+ setInterval(function () {
+ Update();
+ }, 1000);
+ });
+
}
//swichting mode
if (mode == 4) {
@@ -403,14 +437,15 @@ optional:
return height;
},
eventRender: function (calEvent, $event) {
- if (calEvent.end.getTime() < new Date().getTime()) {
+ if (calEvent.end.getTime() < new myDate().getTime()) {
$event.css("backgroundColor", "#aaa");
$event.find(".time").css({"backgroundColor": "#999", "border": "1px solid #888"});
- } else if (calEvent.end.getTime() > new Date().getTime() && calEvent.start.getTime() < new Date().getTime()) {
+ } else if (calEvent.end.getTime() > new myDate().getTime() && calEvent.start.getTime() < new myDate().getTime()) {
$event.css("backgroundColor", "#25B002");
$event.find(".time").css({"backgroundColor": "#25B002", "border": "1px solid #888"});
}
},
+ date:myDate(),
dateFormat: "d M y",
timeFormat: "G:i",
use24Hour: true,
@@ -449,12 +484,14 @@ optional:
openingTimes = [parsedOpenings['Sunday'], parsedOpenings['Monday'], parsedOpenings['Tuesday'],
parsedOpenings['Wednesday'], parsedOpenings['Thursday'],
parsedOpenings['Friday'], parsedOpenings['Saturday']];
-
+ if(mode == 3) {
+ return;
+ }
for (var i = 0; i < 7; i++) {
var tmp = openingTimes[i];
if (tmp != null) {
for (var d = 0; d < tmp.length; d++) {
- var day = getNextDayOfWeek(new Date(), i);
+ var day = getNextDayOfWeek(new myDate(), i);
openingTimesCalendar.push({
"start": new Date(day.getFullYear(), day.getMonth(), day.getDate(),
tmp[d]['HourOpen'], tmp[d]['MinutesOpen']),
@@ -518,15 +555,22 @@ optional:
if (openTimes == null) {
return;
}
- var clientHeight = $(window).height() - document.getElementById('header').clientHeight - document.getElementsByClassName("wc-time-column-header")[0].clientHeight - 10;
+ var cal = $('#calendar');
+ if(document.getElementsByClassName("wc-day-1")[0].clientWidth < 85){
+ cal.weekCalendar("option", "useShortDayNames", true);
+ } else {
+ cal.weekCalendar("option", "useShortDayNames", false);
+ }
+ var clientHeight = $(window).height() - document.getElementById('header').clientHeight - document.getElementsByClassName("wc-time-column-header")[0].clientHeight-10 ;
if (mode == 1 && verticalmode) {
- clientHeight -= 20;
+
clientHeight = clientHeight * (scaleLayout / 100);
+ clientHeight -= 22;
}
- var cal = $('#calendar');
- var height = clientHeight / (openTimes * cal.weekCalendar("option", "timeslotsPerHour"));
+
+ var height = clientHeight / (openTimes * cal.weekCalendar("option", "timeslotsPerHour"));
cal.weekCalendar("option", "timeslotHeight", height);
cal.weekCalendar("updateFreeBusy", openingTimesCalendar);
}
@@ -560,7 +604,7 @@ optional:
return hours + ":" + minutes + ":" + seconds;
}
function GetNextClosing() {
- var now = new Date();
+ var now = new myDate();
var day = now.getDay();
var offset = 0;
var bestdate;
@@ -568,8 +612,8 @@ optional:
var tmp = openingTimes[day];
if (tmp != null) {
for (var i = 0; i < tmp.length; i++) {
- var closeDate = new Date();
- closeDate.setDate(now.getDate() + offset)
+ var closeDate = new myDate();
+ closeDate.setDate(now.getDate() + offset);
closeDate.setHours(tmp[i].HourClose);
closeDate.setMinutes(tmp[i].MinutesClose);
if (closeDate > now) {
@@ -593,16 +637,16 @@ optional:
* @return {boolean}
*/
function IsOpenNow() {
- var now = new Date();
+ var now = new myDate();
var tmp = openingTimes[now.getDay()];
if (tmp == null) {
return false;
}
for (var i = 0; i < tmp.length; i++) {
- var openDate = new Date();
+ var openDate = new myDate();
openDate.setHours(tmp[i].HourOpen);
openDate.setMinutes(tmp[i].MinutesOpen);
- var closeDate = new Date();
+ var closeDate = new myDate();
closeDate.setHours(tmp[i].HourClose);
closeDate.setMinutes(tmp[i].MinutesClose);
if (openDate < now && closeDate > now) {
@@ -621,10 +665,10 @@ optional:
return false;
}
for (var i = 0; i < tmp.length; i++) {
- var openDate = new Date();
+ var openDate = new myDate();
openDate.setHours(tmp[i].HourOpen);
openDate.setMinutes(tmp[i].MinutesOpen);
- var closeDate = new Date();
+ var closeDate = new myDate();
closeDate.setHours(tmp[i].HourClose);
closeDate.setMinutes(tmp[i].MinutesClose);
if (openDate < date && closeDate > date) {
@@ -636,7 +680,7 @@ optional:
function GetNextOpening() {
- var now = new Date();
+ var now = new myDate();
var day = now.getDay();
var offset = 0;
var bestdate;
@@ -644,8 +688,8 @@ optional:
var tmp = openingTimes[day];
if (tmp != null) {
for (var i = 0; i < tmp.length; i++) {
- var openDate = new Date();
- openDate.setDate(now.getDate() + offset)
+ var openDate = new myDate();
+ openDate.setDate(now.getDate() + offset);
openDate.setHours(tmp[i].HourOpen);
openDate.setMinutes(tmp[i].MinutesOpen);
if (openDate > now) {
@@ -687,17 +731,18 @@ optional:
return;
}
if (tmp.state == "closed") {
- $("#courseHeading").text(t("closed") + " " + GetTimeDiferenceAsString(tmp.end, new Date()));
+ $("#courseHeading").text(t("closed") + " " + GetTimeDiferenceAsString(tmp.end, new myDate()));
SetFreeSeats(-1);
} else if (tmp.state == "ClaendarEvent") {
$("#courseHeading").text(state.titel);
SetFreeSeats(-1);
} else if (tmp.state == "Free") {
- $("#courseHeading").text(t("free") + " " + GetTimeDiferenceAsString(tmp.end, new Date()));
+ $("#courseHeading").text(t("free") + " " + GetTimeDiferenceAsString(tmp.end, new myDate()));
} else if (tmp.state == "FreeNoEnd") {
$("#courseHeading").text(t("free"));
}
- var now = new Date();
+ var now = new myDate();
+ //console.log(now.getHours()+":"+now.getMinutes()+":"+now.getSeconds());
// reload if date Changes
if (date != null) {
if (date.getDate() != now.getDate()) {
@@ -713,7 +758,7 @@ optional:
return state;
}
if (state.end != "") {
- if (state.end < new Date()) {
+ if (state.end < new myDate()) {
ComputeCurrentState();
}
}
@@ -740,7 +785,7 @@ optional:
}
// event is at the moment
- if (event.start.getTime() < closing.getTime() && event.start.getTime() < new Date()) {
+ if (event.start.getTime() < closing.getTime() && event.start.getTime() < new myDate()) {
state = {state: "ClaendarEvent", end: event.end, titel: event.title, next: ""};
return;
}
@@ -761,7 +806,7 @@ optional:
function getNextEvent(json) {
var event;
- var now = new Date();
+ var now = new myDate();
for (var i = 0; i < json.length; i++) {
//event is now active
if (json[i].start.getTime() < now.getTime() && json[i].end.getTime() > now.getTime()) {
@@ -810,10 +855,11 @@ optional:
var div = document.createElement("div");
div.id = "roomLayout";
div.className = "roomLayoutDesign";
- if ((verticalmode && mode == 1) || (mode == 3)) {
+ if ((verticalmode && mode == 1) || (mode == 3)|| (mode == 4)) {
width = 100 + "%";
div.float = "Top";
}
+
div.style.width = width;
document.body.appendChild(div);
}
@@ -824,10 +870,13 @@ optional:
}
function initRoom(Json, scale) {
+
Layout = Json;
+ if(Layout == null||Layout.length == 0 ||Layout[0].x == null || Layout[0].y == null) {
+ return;
+ }
generateRoomLayoutDiv(scale);
- if (rotation != null) {
- if (rotation > 0 && rotation < 4)
+ if (rotation != 0) {
rotateRoom(rotation);
}
minX = parseInt(Layout[0].x);
@@ -937,29 +986,34 @@ optional:
function scaleRoom() {
for (var i = 0; i < Layout.length; i++) {
- document.getElementById(Layout[i].id).width = (picSizeX * scale);
- document.getElementById(Layout[i].id).height = (picSizeY * scale);
- document.getElementById(Layout[i].id).style.left = ((parseInt(Layout[i].x) + xOffset) * scale) + "px";
- document.getElementById(Layout[i].id).style.bottom = ((parseInt(Layout[i].y) + yOffset) * scale ) + "px";
+ if(Layout[i].y!= null & Layout[i].x!=null) {
+ document.getElementById(Layout[i].id).width = (picSizeX * scale);
+ document.getElementById(Layout[i].id).height = (picSizeY * scale);
+ document.getElementById(Layout[i].id).style.left = ((parseInt(Layout[i].x) + xOffset) * scale) + "px";
+ document.getElementById(Layout[i].id).style.top = ((parseInt(Layout[i].y) + yOffset) * scale ) + "px";
+ }
}
}
function UpdatePc(update) {
- var now = new Date();
var freePcs = 0;
for (var i = 0; i < update.length; i++) {
- var img;
- if (update[i].inUse == "0") {
- //add time to prevent caching
- img = "img/pc_free.svg";
- freePcs++;
- } else if (update[i].inUse == "1") {
- img = "img/pc_used.svg";
- } else {
- img = "img/pc_defect.svg?";
+ var imgobj =document.getElementById(update[i].id);
+
+ var img;
+ if (update[i].inUse == "0") {
+ //add time to prevent caching
+ img = "img/pc_free.svg";
+ freePcs++;
+ } else if (update[i].inUse == "1") {
+ img = "img/pc_used.svg";
+ } else {
+ img = "img/pc_defect.svg?";
+ }
+ if(imgobj !=null) {
+ imgobj.src = img;
}
- document.getElementById(update[i].id).src = img;
}
if (state == null || state.state == "FreeNoEnd" || state.state == "Free") {
SetFreeSeats(freePcs);
@@ -975,6 +1029,7 @@ optional:
if (mode != null) {
if (mode != 3) {
scaleCalendar();
+
}
if (mode != 2) {
generateOffsetAndScale();
@@ -1045,6 +1100,8 @@ optional:
}
}
+
+
</script>
</head>
<body>