From 41ff429b1f39f107565365c206cfd6e11c875462 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Tue, 16 Jul 2019 16:06:41 +0200 Subject: [locationinfo] Add ability to select the start day of the calendar --- .../locationinfo/templates/frontend-default.html | 10 +++++-- .../templates/page-config-panel-default.html | 34 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'modules-available/locationinfo/templates') diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html index 98149bb9..c59679ee 100755 --- a/modules-available/locationinfo/templates/frontend-default.html +++ b/modules-available/locationinfo/templates/frontend-default.html @@ -499,7 +499,8 @@ optional: if (!scaleFactor) { scaleFactor = 1; } - if (!v || !isFinite(v) || isNaN(v) || v < min * scaleFactor || v > max * scaleFactor) { + if (v === null || !isFinite(v) || isNaN(v) || v < min * scaleFactor || v > max * scaleFactor) { + console.log(property) config[property] = defaultval * scaleFactor; } } @@ -522,6 +523,7 @@ optional: setRoomConfigFromUrl(config, 'calupdate', PARAM_INT, 60 * 1000); setRoomConfigFromUrl(config, 'roomupdate', PARAM_INT, 1000); + setRoomConfigFromUrl(config, 'startday', PARAM_INT); setRoomConfigFromUrl(config, 'daystoshow', PARAM_INT); setRoomConfigFromUrl(config, 'scaledaysauto', PARAM_BOOL); setRoomConfigFromUrl(config, 'vertical', PARAM_BOOL); @@ -535,6 +537,7 @@ optional: // parameter validation putInRange(config, 'switchtime', 5, 120, 6, 1000); putInRange(config, 'scale', 10, 90, 50); + putInRange(config, 'startday', 0, 7, 0); putInRange(config, 'daystoshow', 1, 7, 7); putInRange(config, 'roomupdate', 15, 5 * 60, 60, 1000); putInRange(config, 'calupdate', 1, 60, 30, 60 * 1000); @@ -738,6 +741,9 @@ optional: */ function setUpCalendar(room) { var daysToShow = room.config.daystoshow; + var startDay = room.config.startday; + var startDayDate = new Date(); + if (startDay > 0) startDayDate.setDate((startDayDate.getDate() - (startDayDate.getDay() + 6) % 7) + (startDay - 1)); generateCalendarDiv(room); room.$.calendar.weekCalendar({ timeslotsPerHour: 1, @@ -765,7 +771,7 @@ optional: $event.find(".time").css({"backgroundColor": "#25B002", "border": "1px solid #888"}); } }, - date: MyDate(), + date: startDayDate, dateFormat: "j.n", timeFormat: "G:i", scrollToHourMillis: 500, diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html index 43a7db44..5e13190e 100644 --- a/modules-available/locationinfo/templates/page-config-panel-default.html +++ b/modules-available/locationinfo/templates/page-config-panel-default.html @@ -191,6 +191,31 @@ +
+
+
+ +
+
+ +
+
+

+ +

+
+
+
+
@@ -385,6 +410,7 @@ document.addEventListener("DOMContentLoaded", function () { addLocation(lids[i], $name.text()); } + $('#startday option[value="{{startday}}"]').attr("selected", "selected"); $('#daystoshow option[value="{{daystoshow}}"]').attr("selected", "selected"); $('#rotation option[value="{{rotation}}"]').attr("selected", "selected"); $('#mode option[value="{{mode}}"]').attr("selected", "selected"); @@ -474,6 +500,11 @@ document.addEventListener("DOMContentLoaded", function () { '
' + '

' + '
')); + $content.append($('
' + + '
' + + '
' + + '

' + + '
')); $content.append($('
' + '
' + '
' + @@ -514,6 +545,7 @@ document.addEventListener("DOMContentLoaded", function () { $('#override' + id + 'roomplanner').val(overrides[id].roomplanner ? 1 : 0); if (overrides[id].vertical) $('#override' + id + 'vertical').bootstrapSwitch('state', true); if (overrides[id].scaledaysauto) $('#override' + id + 'scaledaysauto').bootstrapSwitch('state', true); + $('#override' + id + 'startday').val(overrides[id].startday); $('#override' + id + 'daystoshow').val(overrides[id].daystoshow); $('#override' + id + 'rotation').val(overrides[id].rotation); scale.val(overrides[id].scale); @@ -522,6 +554,8 @@ document.addEventListener("DOMContentLoaded", function () { $('#override' + id + 'roomplanner').val($('#input-roomplanner').val()); if ($('#input-vertical').bootstrapSwitch('state')) $('#override' + id + 'vertical').bootstrapSwitch('state', true); if ($('#scaledaysauto').bootstrapSwitch('state')) $('#override' + id + 'scaledaysauto').bootstrapSwitch('state', true); + console.log($('#startday').val()) + $('#override' + id + 'startday').val($('#startday').val()); $('#override' + id + 'daystoshow').val($('#daystoshow').val()); $('#override' + id + 'rotation').val($('#rotation').val()); scale.val($('#input-scale').val()); -- cgit v1.2.3-55-g7522