diff options
Diffstat (limited to 'www/js/EventCtrl.js')
| -rw-r--r-- | www/js/EventCtrl.js | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 409ecae6..cc50f586 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -108,25 +108,12 @@ angular.module('zmApp.controllers') }); function scrollTo(eventNum, eventPos) { - var eventHeightCounter = 0; - var i = 0; - var lastEventHeight = 0; - //loop until we pass the event... - for (i = 0; i < $scope.events.length; i++) { - lastEventHeight = getRowHeight($scope.events[i]); - if ( i >= eventNum ) { - //$scope.navTitle = ($scope.events[i].Event.humanizeTime); // we don't need to update the navTitle as we're staying in the same place - break; - } - //console.log(getRowHeight($scope.events[i])); - eventHeightCounter = eventHeightCounter + lastEventHeight; - } - var scrl = eventHeightCounter + (lastEventHeight * eventPos); - //console.log("eventHeightCounter: " + eventHeightCounter + " lastEventHeight: " + lastEventHeight + ", scrl To " + scrl + ", len: " + $scope.events.length); - NVR.debug("scrollTo: " + scrl); - $ionicScrollDelegate.$getByHandle("mainScroll").scrollTo(0, scrl, false); - } - + var scrl = (eventRowHeight * eventNum) + (eventRowHeight * eventPos); + //console.log("eventNum: " + eventNum + " eventPos: " + eventPos + ", scrl To " + scrl); + //NVR.debug("scrollTo: " + scrl); + $ionicScrollDelegate.$getByHandle("mainScroll").scrollTo(0, scrl, false); + } + function getRowHeight(event) { var scrubHeight = 274; return event.Event.ShowScrub ? eventRowHeight + scrubHeight : eventRowHeight; @@ -137,7 +124,7 @@ angular.module('zmApp.controllers') var tempMonHeight = 0; monitorHeight = 0; for (var i=0; i < $scope.monitors.length; i++) { - if ($scope.monitors[i] != undefined && $scope.monitors[i].Monitor.isChecked) { + if ($scope.monitors[i] != undefined) { var mw = $scope.monitors[i].Monitor.Width; var mh = $scope.monitors[i].Monitor.Height; var mo = $scope.monitors[i].Monitor.Orientation; @@ -636,20 +623,36 @@ angular.module('zmApp.controllers') if ($rootScope.toString) nolangTo = moment($rootScope.toString).locale('en').format("YYYY-MM-DD HH:mm:ss"); - if ($scope.id) + if ($scope.id) { $rootScope.monitorsFilter = "/MonitorId =:" + $scope.id; - if ($rootScope.monitorsFilter == undefined || $rootScope.monitorsFilter == '' || $scope.id) { - for (var i=0; i < $scope.monitors.length; i++) { - if ($scope.monitors[i] != undefined) { - if ($rootScope.monitorsFilter == undefined || $rootScope.monitorsFilter == '' || $scope.monitors[i].Monitor.Id == $scope.id) - $scope.monitors[i].Monitor.isChecked = true; - else - $scope.monitors[i].Monitor.isChecked = false; + $scope.id = 0; + } + + if ($rootScope.monitorsFilter != undefined && $rootScope.monitorsFilter != '') { + NVR.debug("dorefresh monitorsFilter: " + $rootScope.monitorsFilter); + var monitorIds = []; + ($rootScope.monitorsFilter.split("/")).forEach(function(monitorId, index) { + //console.log('Index: ' + index + ' Value: ' + monitorId); + //skip the first one as it's always blank + if (index) + monitorIds.push(monitorId.split(":")[1]); + }); + var checked = true; + //if include listed monitors + if ($rootScope.monitorsFilter.includes("!=")) { + checked = false; + } + for (var i=0; i < $scope.monitors.length; i++) { + if ($scope.monitors[i] != undefined) { + if (monitorIds.includes($scope.monitors[i].Monitor.Id)) + $scope.monitors[i].Monitor.isChecked = checked; + else + $scope.monitors[i].Monitor.isChecked = !checked; + } } } - } - if ($scope.id) - $scope.id = 0; + + setRowHeight(); |
