From 1f3821047eee8ebc10775e20e87b8b1489177970 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Fri, 16 Oct 2015 14:56:11 +0300 Subject: [PATCH] don't actually enable working schedule unless at least one day is enabled --- motioneye/__init__.py | 2 +- motioneye/static/js/main.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/motioneye/__init__.py b/motioneye/__init__.py index 0c7df6e..dcb5b41 100644 --- a/motioneye/__init__.py +++ b/motioneye/__init__.py @@ -1,2 +1,2 @@ -VERSION = "0.28.1" +VERSION = "0.28.1-git" diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js index d6187fc..ac361fd 100644 --- a/motioneye/static/js/main.js +++ b/motioneye/static/js/main.js @@ -332,6 +332,16 @@ Array.prototype.every = Array.prototype.every || function (callback, thisArg) { return true; }; +Array.prototype.some = Array.prototype.some || function (callback, thisArg) { + for (var i = 0; i < this.length; i++) { + if (callback.call(thisArg, this[i], i, this)) { + return true; + } + } + + return false; +}; + Array.prototype.unique = function (callback, thisArg) { var uniqueElements = []; this.forEach(function (element) { @@ -1385,6 +1395,16 @@ function cameraUi2Dict() { 'sunday_to': $('#sundayEnabledSwitch')[0].checked ? $('#sundayToEntry').val() : '', 'working_schedule_type': $('#workingScheduleTypeSelect').val(), }; + + /* if all working schedule days are disabled, + * also disable the global working schedule */ + var hasWS = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'].some(function (day) { + return $('#' + day + 'EnabledSwitch')[0].checked; + }); + + if (!hasWS) { + dict['working_schedule'] = false; + } if ($('#resolutionSelect')[0].selectedIndex != -1) { dict.resolution = $('#resolutionSelect').val(); -- 2.39.5