summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Hofmaier2019-10-26 13:44:53 +0200
committerChristian Hofmaier2019-10-26 13:44:53 +0200
commit5b25319ba5fc77d6cfb4115b80b885d34509a171 (patch)
tree58e6bcf99514777b801c1164bdc2cad8d3f4cf43
parentconfig.php.emaple: Remove another orphaned config var (diff)
downloadslx-admin-5b25319ba5fc77d6cfb4115b80b885d34509a171.tar.gz
slx-admin-5b25319ba5fc77d6cfb4115b80b885d34509a171.tar.xz
slx-admin-5b25319ba5fc77d6cfb4115b80b885d34509a171.zip
[locationinfo] Make switching per room work
-rw-r--r--modules-available/locationinfo/page.inc.php3
-rwxr-xr-xmodules-available/locationinfo/templates/frontend-default.html81
2 files changed, 43 insertions, 41 deletions
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index 5ba555df..37d68fc0 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -400,7 +400,8 @@ class Page_LocationInfo extends Page
'scaledaysauto' => Request::post('override'.$locationids[$i].'scaledaysauto', false, 'bool'),
'daystoshow' => Request::post('override'.$locationids[$i].'daystoshow', 7, 'int'),
'rotation' => Request::post('override'.$locationids[$i].'rotation', 0, 'int'),
- 'scale' => Request::post('override'.$locationids[$i].'scale', 50, 'int')
+ 'scale' => Request::post('override'.$locationids[$i].'scale', 50, 'int'),
+ 'switchtime' => Request::post('override'.$locationids[$i].'switchtime', 60, 'int')
);
$overrides[$locationids[$i]] = $overrideArray;
}
diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html
index c59679ee..66fb14bd 100755
--- a/modules-available/locationinfo/templates/frontend-default.html
+++ b/modules-available/locationinfo/templates/frontend-default.html
@@ -500,7 +500,6 @@ optional:
scaleFactor = 1;
}
if (v === null || !isFinite(v) || isNaN(v) || v < min * scaleFactor || v > max * scaleFactor) {
- console.log(property)
config[property] = defaultval * scaleFactor;
}
}
@@ -577,7 +576,7 @@ optional:
left = ((t % 2) * 50) + '%';
}
- var $loc = $("<div>").addClass('location-container');
+ var $loc = $("<div>").addClass('location-container').attr('id', rid);
$loc.css({top: top, left: left, width: width, height: height});
$("body").append($loc);
@@ -628,7 +627,7 @@ optional:
}
if (hasMode4) {
- generateProgressBar();
+ generateRoomSwitchIntervals();
}
mainUpdateLoop();
@@ -1614,7 +1613,6 @@ optional:
scaleCalendar(rooms[property]);
scaleRoom(rooms[property]);
}
- SetProgressBarSpeed();
}, 200);
});
@@ -1663,56 +1661,59 @@ optional:
}
}
-
/**
* Used in Mode 4, switches given room from Timetable to room layout and vice versa
*/
- function switchLayouts() {
+ roomSwitchIntervals = [];
+ progressBarUpdateIntervals = [];
+ lastSwitchTimes = [];
+
+ function switchRoomLayout(room) {
+ if (room.config.mode !== 4) return;
+ if (room.$.layout.is(':visible')) {
+ room.$.layout.hide();
+ room.$.calendar.show();
+ } else {
+ room.$.layout.show();
+ room.$.calendar.hide();
+ }
+ lastSwitchTimes[room.id] = MyDate().getTime();
+ resizeIfRequired(room);
+
+ }
+
+ function generateRoomSwitchIntervals() {
for (var roomKey in rooms) {
- var room = rooms[roomKey];
+ const room = rooms[roomKey];
if (room.config.mode !== 4) continue;
- if (room.$.layout.is(':visible')) {
- room.$.layout.hide();
- room.$.calendar.show();
- } else {
- room.$.layout.show();
- room.$.calendar.hide();
- }
- resizeIfRequired(room);
+ if (roomSwitchIntervals[room.id]) clearInterval(roomSwitchIntervals[room.id]);
+ lastSwitchTimes[room.id] = MyDate().getTime();
+ generateProgressBar(room);
+ var interval = room.config.switchtime;
+ roomSwitchIntervals[room.id] = setInterval(function () {
+ switchRoomLayout(room);
+ }, interval);
}
- lastSwitchTime = MyDate().getTime();
}
- var $pbar = false;
- var pbarTimer = false;
- const PX_PER_SEC_TARGET = 10;
+ function generateProgressBar(room) {
+ if ($('#progressbar_' + room.id).length > 0 ) return;
+ var $progressBar = $('<div class="progressbar">').attr('id', 'progressbar_' + room.id);
+ $('#' + room.id).append($progressBar);
- /**
- * adds a progressbar (id) used in mode 4
- */
- function generateProgressBar() {
- if ($pbar) return;
- $pbar = $('<div class="progressbar">');
- $('body').append($pbar);
- SetProgressBarSpeed();
- }
+ if (progressBarUpdateIntervals[room.id]) clearInterval(progressBarUpdateIntervals[room.id]);
- function SetProgressBarSpeed() {
- if (!$pbar || !globalConfig.switchtime) return;
- if (pbarTimer) clearInterval(pbarTimer);
var interval = 1000;
if (!globalConfig.eco) {
- var pxPerMSec = $('body').width() / globalConfig.switchtime;
- interval = Math.max(1 / (pxPerMSec / PX_PER_SEC_TARGET), 100);
+ var pxPerMSec = $('body').width() / room.config.switchtime;
+ interval = Math.max(1 / (pxPerMSec / 100), 100);
}
- pbarTimer = setInterval(function () {
- var width = ((MyDate().getTime() - lastSwitchTime) / globalConfig.switchtime) * 100;
+
+ progressBarUpdateIntervals[room.id] = setInterval(function() {
+ var width = ((MyDate().getTime() - lastSwitchTimes[room.id]) / room.config.switchtime) * 100;
if (width < 0) width = 0;
- if (width >= 100) {
- width = 100;
- switchLayouts();
- }
- $pbar.width(width + '%');
+ if (width >= 100) width = 100;
+ $('#progressbar_' + room.id).width(width + '%');
}, interval);
}