From 7eb5a9281ff24f13e50c0cd068df96660b1a1d81 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 9 Nov 2016 14:32:36 -0500 Subject: Added event time progression to video #362 --- www/js/EventModalCtrl.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index abdf5052..94c11e25 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -6,7 +6,7 @@ -angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate) { +angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter) { // from parent scope @@ -775,7 +775,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.scaleImage = function () { $scope.imageFit = !$scope.imageFit; - // console.log("Switching image style to " + $scope.imageFit); + console.log("Switching image style to " + $scope.imageFit); }; $scope.$on('$ionicView.enter', function () { @@ -907,6 +907,25 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); } + $scope.videoTime = function(s,c) + { + var a,o; + if (NVRDataModel.getLogin().useLocalTimeZone) + { + a = moment.tz(s, NVRDataModel.getTimeZoneNow()).tz(moment.tz.guess()); + + } + else + { + a = moment(s); + } + a.add(c); + + o = a.format("MMM Do "+NVRDataModel.getTimeFormatSec()); + $scope.videoDynamicTime = o; + //return a.format("MMM Do "+o); + + }; $scope.$on('modal.removed', function (e, m) { console.log ("************* REMOVE CALLED"); @@ -1467,6 +1486,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.videoObject = { config: { autoPlay: true, + responsive:true, + nativeControls:false, playsInline:true, sources: [ -- cgit v1.2.3 From 8b4c11e4e234f1eb52bb16322bacd00c455879f0 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 9 Nov 2016 16:41:28 -0500 Subject: some more tweaks to h264 video display given its all the rage now --- www/js/EventModalCtrl.js | 1 + 1 file changed, 1 insertion(+) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 94c11e25..628cc1ff 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -791,6 +791,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro return; + $scope.videoDynamicTime = ""; $scope.videoIsReady = false; var ld = NVRDataModel.getLogin(); $scope.loginData = NVRDataModel.getLogin(); -- cgit v1.2.3 From 445dbcf856901bde8175829edf3a08400f830d56 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Thu, 10 Nov 2016 15:00:11 -0500 Subject: video automatically fits to screen #358 --- www/js/EventModalCtrl.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 628cc1ff..d4dcf3f0 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -6,7 +6,7 @@ -angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter) { +angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', 'SecuredPopups', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter, SecuredPopups) { // from parent scope @@ -181,7 +181,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.onVideoError = function (event) { + if (!$scope.isModalActive) return; NVRDataModel.debug ("player reported a video error:"+JSON.stringify(event)); + $rootScope.zmPopup = SecuredPopups.show('alert', { + title: $translate.instant('kError'), + template: $rootScope.platformOS == 'desktop' ?$translate.instant('kVideoError'):$translate.instant('kVideoErrorMobile') + }); + }; @@ -1487,7 +1493,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.videoObject = { config: { autoPlay: true, - responsive:true, + responsive:false, nativeControls:false, playsInline:true, -- cgit v1.2.3 From 106c5c2c1617fa6685afd7ec2d9afc306e795cf0 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 11 Nov 2016 10:53:38 -0500 Subject: disabled graph drawing and timers if h264 is played --- www/js/EventModalCtrl.js | 325 +++++++++++++++++++++++------------------------ 1 file changed, 156 insertions(+), 169 deletions(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index d4dcf3f0..9067bd0e 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -6,7 +6,7 @@ -angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', 'SecuredPopups', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter, SecuredPopups) { +angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', 'SecuredPopups', function($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter, SecuredPopups) { // from parent scope @@ -26,7 +26,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro backgroundColor: 'rgba(242, 12, 12, 0.5)', borderColor: 'rgba(242, 12, 12, 0.5)', data: [], - }] + }] }; var frameoptions = []; @@ -40,7 +40,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro progress: 0 }; NVRDataModel.getKeyConfigParams(0) - .then(function (data) { + .then(function(data) { //console.log ("***GETKEY: " + JSON.stringify(data)); eventImageDigits = parseInt(data); NVRDataModel.log("Image padding digits reported as " + eventImageDigits); @@ -55,7 +55,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.isModalActive = true; - $timeout(function () { + $timeout(function() { $scope.showModalRangeSider = true; }, 2000); @@ -88,29 +88,29 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $rootScope.validMonitorId = $scope.monitors[0].Monitor.Id; NVRDataModel.getAuthKey($rootScope.validMonitorId, (Math.floor((Math.random() * 999999) + 1)).toString()) - .then(function (success) { + .then(function(success) { $ionicLoading.hide(); $rootScope.authSession = success; NVRDataModel.log("Modal: Stream authentication construction: " + $rootScope.authSession); }, - function (error) { + function(error) { $ionicLoading.hide(); NVRDataModel.debug("ModalCtrl: Error details of stream auth:" + error); //$rootScope.authSession=""; NVRDataModel.log("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); }); - - - + + + //-------------------------------------------------------------------------------------- // Handles bandwidth change, if required // //-------------------------------------------------------------------------------------- - $rootScope.$on("bandwidth-change", function (e,data) { - // not called for offline, I'm only interested in BW switches + $rootScope.$on("bandwidth-change", function(e, data) { + // not called for offline, I'm only interested in BW switches NVRDataModel.debug("Got network change:" + data); var ds; if (data == 'lowbw') { @@ -121,8 +121,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.displayBanner('net', [ds]); var ld = NVRDataModel.getLogin(); - - $scope.singleImageQuality = (NVRDataModel.getBandwidth()=="lowbw" )? zm.eventSingleImageQualityLowBW: ld.singleImageQuality; + + $scope.singleImageQuality = (NVRDataModel.getBandwidth() == "lowbw") ? zm.eventSingleImageQualityLowBW : ld.singleImageQuality; }); @@ -133,13 +133,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //------------------------------------------------------ - $rootScope.$on("auth-success", function () { + $rootScope.$on("auth-success", function() { NVRDataModel.debug("EventModalCtrl: Re-login detected, resetting everything & re-generating connkey"); NVRDataModel.stopNetwork("Auth-Success inside EventModalCtrl"); $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); //console.log ("********* OFFSET FROM AUTH SUCC"); - $timeout(function () { + $timeout(function() { sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); }, 500); //$timeout.cancel(eventQueryHandle); @@ -153,7 +153,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // tap to pause //------------------------------------------------------ - $scope.togglePause = function () { + $scope.togglePause = function() { $scope.isPaused = !$scope.isPaused; NVRDataModel.debug("Paused is " + $scope.isPaused); @@ -163,30 +163,27 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }; - $scope.onPlayerReady = function(handle) - { + $scope.onPlayerReady = function(handle) { // we need this timeout to avoid load interrupting // play -- I suppose its an angular digest foo thing - NVRDataModel.debug ("Player is ready"); - $timeout (function() {handle.play();},400); - - // window.stop(); + NVRDataModel.debug("Player is ready"); + $timeout(function() { handle.play(); }, 400); + + // window.stop(); }; - $scope.onCanPlay = function () - { - NVRDataModel.debug ("This video can be played"); + $scope.onCanPlay = function() { + NVRDataModel.debug("This video can be played"); }; - $scope.onVideoError = function (event) - { + $scope.onVideoError = function(event) { if (!$scope.isModalActive) return; - NVRDataModel.debug ("player reported a video error:"+JSON.stringify(event)); + NVRDataModel.debug("player reported a video error:" + JSON.stringify(event)); $rootScope.zmPopup = SecuredPopups.show('alert', { - title: $translate.instant('kError'), - template: $rootScope.platformOS == 'desktop' ?$translate.instant('kVideoError'):$translate.instant('kVideoErrorMobile') - }); + title: $translate.instant('kError'), + template: $rootScope.platformOS == 'desktop' ? $translate.instant('kVideoError') : $translate.instant('kVideoErrorMobile') + }); }; @@ -198,14 +195,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //------------------------------------------------------ function checkEvent() { - - if ($scope.modalFromTimelineIsOpen == false) - { - NVRDataModel.log ("Modal was closed in timeline, cancelling timer"); + + if ($scope.modalFromTimelineIsOpen == false) { + NVRDataModel.log("Modal was closed in timeline, cancelling timer"); $interval.cancel(eventQueryHandle); return; } - + //console.log ("Event timer"); //console.log ("Event timer"); $scope.checkEventOn = true; @@ -241,7 +237,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro 'Content-Type': 'application/x-www-form-urlencoded', //'Accept': '*/*', }, - transformRequest: function (obj) { + transformRequest: function(obj) { var str = []; for (var p in obj) str.push(encodeURIComponent(p) + "=" + @@ -266,14 +262,14 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // pass: loginData.password } }) - .then(function (resp) { + .then(function(resp) { NVRDataModel.debug("sendCmd response:" + JSON.stringify(resp)); d.resolve(resp); return (d.promise); }, - function (resp) { + function(resp) { NVRDataModel.debug("sendCmd error:" + JSON.stringify(resp)); d.reject(resp); return (d.promise); @@ -302,7 +298,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro 'Content-Type': 'application/x-www-form-urlencoded', //'Accept': '*/*', }, - transformRequest: function (obj) { + transformRequest: function(obj) { var str = []; for (var p in obj) str.push(encodeURIComponent(p) + "=" + @@ -323,7 +319,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } }); - req.success(function (resp) { + req.success(function(resp) { // NVRDataModel.debug ("processEvent success:"+JSON.stringify(resp)); if (resp.result == "Ok") { @@ -356,7 +352,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); // console.log (JSON.stringify(resp)); - $timeout(function () { + $timeout(function() { sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); }, 500); NVRDataModel.debug("so I'm regenerating Connkey to " + $scope.connKey); @@ -365,7 +361,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); - req.error(function (resp) { + req.error(function(resp) { NVRDataModel.debug("processEvent error:" + JSON.stringify(resp)); //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); @@ -401,24 +397,24 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro - $scope.finishedLoadingImage = function () { + $scope.finishedLoadingImage = function() { // console.log("***Monitor image FINISHED Loading***"); $ionicLoading.hide(); }; - $scope.enableSliderBlock = function () { + $scope.enableSliderBlock = function() { $scope.blockSlider = true; }; - $scope.youChangedSlider = function () { + $scope.youChangedSlider = function() { //console.log("YOU changed " + $scope.sliderProgress.progress); $scope.currentProgress.progress = $scope.sliderProgress.progress; sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress) - .then (function (s) { $scope.blockSlider = false; }, function (e) {$scope.blockSlider = false;}); - - + .then(function(s) { $scope.blockSlider = false; }, function(e) { $scope.blockSlider = false; }); + + }; @@ -450,7 +446,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - $scope.jumpToOffsetInEvent = function () { + $scope.jumpToOffsetInEvent = function() { // streamReq.send( streamParms+"&command="+CMD_SEEK+"&offset="+offset ); }; @@ -460,41 +456,37 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // Saves a snapshot of the monitor image to phone storage //----------------------------------------------------------------------- - - $scope.saveEventImageToPhoneWithPerms = function (onlyAlarms) - { - - if ($rootScope.platformOS != 'android') - { + + $scope.saveEventImageToPhoneWithPerms = function(onlyAlarms) { + + if ($rootScope.platformOS != 'android') { processSaveEventImageToPhone(onlyAlarms); return; } - + // if we are on android do the 6.x+ hasPermissions flow NVRDataModel.debug("EventModalCtrl: Permission checking for write"); var permissions = cordova.plugins.permissions; permissions.hasPermission(permissions.WRITE_EXTERNAL_STORAGE, checkPermissionCallback, null); - + function checkPermissionCallback(status) { - if (!status.hasPermission) - { + if (!status.hasPermission) { SaveError("No permission to write to external storage"); } - permissions.requestPermission(permissions.WRITE_EXTERNAL_STORAGE, succ,err); + permissions.requestPermission(permissions.WRITE_EXTERNAL_STORAGE, succ, err); } - - function succ(s) - { + + function succ(s) { processSaveEventImageToPhone(onlyAlarms); } - function err(e) - { - SaveError ("Error in requestPermission"); + + function err(e) { + SaveError("Error in requestPermission"); } }; - - - function processSaveEventImageToPhone (onlyAlarms) { + + + function processSaveEventImageToPhone(onlyAlarms) { if ($scope.loginData.useNphZmsForEvents) { NVRDataModel.log("Use ZMS stream to save to phone"); @@ -521,7 +513,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro duration: zm.httpTimeout }); sendCommand('1', $scope.connKey). - then(function (resp) { + then(function(resp) { // console.log ("PAUSE ANSWER IS " + JSON.stringify(resp)); $scope.currentProgress.progress = resp.data.status.progress; @@ -531,7 +523,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var apiurl = $scope.loginData.apiurl + "/events/" + $scope.eventId + ".json"; NVRDataModel.debug("prepared to get frame details using " + apiurl); $http.get(apiurl) - .then(function (success) { + .then(function(success) { var event = success.data.event; @@ -558,7 +550,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // console.log ("STEP 1 : Computed index as "+ $scope.mycarousel.index); var i; for (i = 1; i <= event.Frame.length; i++) { - var fname = padToN(event.Frame[i-1].FrameId, eventImageDigits) + "-capture.jpg"; + var fname = padToN(event.Frame[i - 1].FrameId, eventImageDigits) + "-capture.jpg"; // console.log ("Building " + fname); // console.log ("DUMPING ONE " + JSON.stringify(event.Frame[i-1])); @@ -566,7 +558,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro if (onlyAlarms) { if (event.Frame[i - 1] && event.Frame[i - 1].Type == 'Alarm') { $scope.slides.push({ - id: event.Frame[i-1].FrameId, + id: event.Frame[i - 1].FrameId, img: fname, }); //console.log ("ALARM PUSHED " + fname); @@ -574,12 +566,12 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } else // push all frames { $scope.slides.push({ - id: event.Frame[i-1].FrameId, + id: event.Frame[i - 1].FrameId, img: fname, }); //console.log ("PUSHED " + fname); } - + } // console.log ("STEP 2 : calling Save Event To Phone"); $ionicLoading.hide(); @@ -587,7 +579,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }, - function (err) { + function(err) { $ionicLoading.hide(); NVRDataModel.log("snapshot API Error: Could not get frames " + JSON.stringify(err)); @@ -599,7 +591,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); }, - function (err) { + function(err) { NVRDataModel.debug("Error pausing stream before snapshot " + JSON.stringify(err)); $ionicLoading.hide(); } @@ -631,7 +623,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.slideIndex = $scope.mycarousel.index; $scope.slideLastIndex = $scope.slides.length - 1; - // console.log ("URL TO DISPLAY " + url); + // console.log ("URL TO DISPLAY " + url); $rootScope.zmPopup = $ionicPopup.show({ @@ -640,38 +632,35 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro subTitle: 'use left and right arrows to change', scope: $scope, cssClass: 'popup95', - buttons: [ - { + buttons: [{ // left 1 text: '', type: 'button-small button-energized ion-chevron-left', - onTap: function (e) { + onTap: function(e) { if ($scope.slideIndex > 0) $scope.slideIndex--; $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img; //NVRDataModel.log("selected frame is " + $scope.slideIndex); - console.log ("URL TO DISPLAY " + $scope.slides[$scope.slideIndex].img); - + console.log("URL TO DISPLAY " + $scope.slides[$scope.slideIndex].img); + e.preventDefault(); } - }, - { + }, { // right 1 text: '', type: 'button-small button-energized ion-chevron-right', - onTap: function (e) { + onTap: function(e) { if ($scope.slideIndex < $scope.slideLastIndex) $scope.slideIndex++; $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img; //NVRDataModel.log("selected frame is " + $scope.slideIndex); - console.log ("URL TO DISPLAY " + $scope.slides[$scope.slideIndex].img); + console.log("URL TO DISPLAY " + $scope.slides[$scope.slideIndex].img); e.preventDefault(); } - }, - { + }, { // left 10 text: '', type: 'button-small button-energized ion-skip-backward', - onTap: function (e) { + onTap: function(e) { var tempVar = $scope.slideIndex; tempVar -= 10; if (tempVar < 0) tempVar = 0; @@ -682,12 +671,11 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro e.preventDefault(); } - }, - { + }, { // right 10 text: '', type: 'button-small button-energized ion-skip-forward', - onTap: function (e) { + onTap: function(e) { var tempVar = $scope.slideIndex; tempVar += 10; if (tempVar > $scope.slideLastIndex) tempVar = $scope.slideLastIndex; @@ -702,15 +690,15 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro { text: '', type: 'button-assertive button-small ion-close-round' - }, - { + }, { text: '', type: 'button-positive button-small ion-checkmark-round', - onTap: function (e) { + onTap: function(e) { saveNow(); } - }] + } + ] }); function saveNow() { @@ -723,7 +711,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.log("saveNow: File path to grab is " + url); var img = new Image(); - img.onload = function () { + img.onload = function() { // console.log("********* ONLOAD"); canvas = document.createElement('canvas'); canvas.width = img.width; @@ -756,7 +744,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro fname = fname.replace(/\//, "-"); fname = fname.replace(/\.jpg/, ''); - canvas.toBlob(function (blob) { + canvas.toBlob(function(blob) { saveAs(blob, fname); SaveSuccess(); }); @@ -772,26 +760,26 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - $scope.reloadView = function () { + $scope.reloadView = function() { NVRDataModel.log("Reloading view for modal view, recomputing rand"); $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); $scope.isModalActive = true; }; - $scope.scaleImage = function () { + $scope.scaleImage = function() { $scope.imageFit = !$scope.imageFit; - console.log("Switching image style to " + $scope.imageFit); + console.log("Switching image style to " + $scope.imageFit); }; - $scope.$on('$ionicView.enter', function () { + $scope.$on('$ionicView.enter', function() { //console.log (">>>>>>>>>>>>>>>>>>>> MODAL VIEW ENTER"); }); - $scope.$on('modal.shown', function (e, m) { + $scope.$on('modal.shown', function(e, m) { if (m.id != 'footage') @@ -802,7 +790,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var ld = NVRDataModel.getLogin(); $scope.loginData = NVRDataModel.getLogin(); - $scope.singleImageQuality = (NVRDataModel.getBandwidth()=="lowbw" )? zm.eventSingleImageQualityLowBW: ld.singleImageQuality; + $scope.singleImageQuality = (NVRDataModel.getBandwidth() == "lowbw") ? zm.eventSingleImageQualityLowBW : ld.singleImageQuality; $scope.blockSlider = false; $scope.checkEventOn = false; //$scope.singleImageQuality = 100; @@ -827,7 +815,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log ("************ CALLING PREPARE MODAL ***********"); prepareModalEvent(currentEvent.Event.Id); if (ld.useNphZmsForEvents) { - $timeout(function () { + $timeout(function() { if ($scope.modal != undefined && $scope.modal.isShown()) { NVRDataModel.log(">>>Starting checkAllEvents interval..."); @@ -835,10 +823,10 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //eventQueryHandle = $timeout (checkEvent(), zm.eventPlaybackQuery); $interval.cancel(eventQueryHandle); - eventQueryHandle = $interval(function () { + eventQueryHandle = $interval(function() { checkEvent(); // console.log ("Refreshing Image..."); - }.bind(this), (NVRDataModel.getBandwidth()=="lowbw")? zm.eventPlaybackQueryLowBW: zm.eventPlaybackQuery); + }.bind(this), (NVRDataModel.getBandwidth() == "lowbw") ? zm.eventPlaybackQueryLowBW : zm.eventPlaybackQuery); } else { NVRDataModel.log(">>>Modal was exited, not starting checkAllEvents"); } @@ -878,7 +866,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro labelString: 'value', } - }], + }], xAxes: [{ type: 'time', display: false, @@ -902,7 +890,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }; - $timeout(function () { + $timeout(function() { var myChart = new Chart(ctx, { @@ -914,28 +902,24 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); } - $scope.videoTime = function(s,c) - { - var a,o; - if (NVRDataModel.getLogin().useLocalTimeZone) - { + $scope.videoTime = function(s, c) { + var a, o; + if (NVRDataModel.getLogin().useLocalTimeZone) { a = moment.tz(s, NVRDataModel.getTimeZoneNow()).tz(moment.tz.guess()); - } - else - { + } else { a = moment(s); } - a.add(c); + a.add(c); - o = a.format("MMM Do "+NVRDataModel.getTimeFormatSec()); + o = a.format("MMM Do " + NVRDataModel.getTimeFormatSec()); $scope.videoDynamicTime = o; //return a.format("MMM Do "+o); }; - $scope.$on('modal.removed', function (e, m) { - console.log ("************* REMOVE CALLED"); + $scope.$on('modal.removed', function(e, m) { + console.log("************* REMOVE CALLED"); $interval.cancel(eventQueryHandle); if (m.id != 'footage') return; @@ -952,7 +936,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // Playback speed adjuster - $scope.adjustSpeed = function (val) { + $scope.adjustSpeed = function(val) { if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { @@ -995,11 +979,11 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); sendCommand(cmd, $scope.connKey) - .then(function (success) { + .then(function(success) { $ionicLoading.hide(); }, - function (err) { + function(err) { $ionicLoading.hide(); NVRDataModel.debug("Error in adjust speed: " + JSON.stringify(err)); } @@ -1052,7 +1036,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }; - $scope.toggleGapless = function () { + $scope.toggleGapless = function() { // console.log(">>>>>>>>>>>>>>GAPLESS TOGGLE INSIDE MODAL"); $scope.loginData.gapless = !$scope.loginData.gapless; NVRDataModel.setLogin($scope.loginData); @@ -1062,7 +1046,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.debug("Regenerating connkey as gapless has changed"); // console.log ("********* OFFSET FROM TOGGLE GAPLESS"); $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); - $timeout(function () { + $timeout(function() { sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); }, 500); //$timeout.cancel(eventQueryHandle); @@ -1083,7 +1067,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro next: "" }; $http.get(myurl) - .success(function (data) { + .success(function(data) { // In Timeline view, gapless should stick to the same monitor if ($scope.followSameMonitor == "1") // we are viewing only one monitor @@ -1102,7 +1086,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro d.resolve(neighbors); return (d.promise); }) - .error(function (err) { + .error(function(err) { NVRDataModel.log("Error retrieving neighbors" + JSON.stringify(err)); d.reject(neighbors); return (d.promise); @@ -1114,7 +1098,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - $scope.zoomImage = function (val) { + $scope.zoomImage = function(val) { var zl = parseInt($ionicScrollDelegate.$getByHandle("imgscroll").getScrollPosition().zoom); if (zl == 1 && val == -1) { NVRDataModel.debug("Already zoomed out max"); @@ -1133,7 +1117,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //Navigate to next/prev event in full screen mode //-------------------------------------------------------- - $scope.onSwipeEvent = function (eid, dirn) { + $scope.onSwipeEvent = function(eid, dirn) { //console.log("HERE"); var ld = NVRDataModel.getLogin(); if (!ld.canSwipeMonitors) return; @@ -1157,7 +1141,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }; - $scope.jumpToEvent = function (eid, dirn) { + $scope.jumpToEvent = function(eid, dirn) { // console.log("jumptoevent"); var ld = NVRDataModel.getLogin(); if (ld.useNphZmsForEvents) { @@ -1204,7 +1188,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.animationInProgress = true; // give digest time for image to swap // 100 should be enough - $timeout(function () { + $timeout(function() { element.removeClass(slideout); element.addClass(slidein) .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', inWithNew); @@ -1220,13 +1204,12 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - function humanizeTime(str) - { + function humanizeTime(str) { // if (NVRDataModel.getLogin().useLocalTimeZone) - return moment.tz(str, NVRDataModel.getTimeZoneNow()).fromNow(); - // else + return moment.tz(str, NVRDataModel.getTimeZoneNow()).fromNow(); + // else // return moment(str).fromNow(); - + } function jumpToEventZms(connkey, dirn) { @@ -1255,17 +1238,17 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("Send command connkey: " + connkey); sendCommand(cmd, connkey) .then( - function (success) { + function(success) { //console.log ("jump success " + JSON.stringify(success)); $ionicLoading.hide(); }, - function (error) { + function(error) { NVRDataModel.debug("Hmm jump error " + JSON.stringify(error)); NVRDataModel.stopNetwork("EventModalCtrl-jumptoEventZms error"); $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); // console.log ("********* OFFSET FROM JUMPTOEVENTZMS ERROR"); - $timeout(function () { + $timeout(function() { sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); }, 500); NVRDataModel.debug("so I'm regenerating Connkey to " + $scope.connKey); @@ -1291,7 +1274,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro - $timeout(function () { + $timeout(function() { element.removeClass(slideout); element.addClass(slidein) .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', inWithNew); @@ -1364,7 +1347,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // Called when rncarousel or video player finished playing event //------------------------------------------------------------------------- - $scope.playbackFinished = function () { + $scope.playbackFinished = function() { playbackFinished(); }; @@ -1375,17 +1358,17 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro if ($scope.loginData.gapless) { neighborEvents(currentEvent.Event.Id) - .then(function (success) { + .then(function(success) { // lets give a second before gapless transition to the next event - $timeout(function () { + $timeout(function() { $scope.nextId = success.next; $scope.prevId = success.prev; NVRDataModel.debug("Gapless move to event " + $scope.nextId); jumpToEvent($scope.nextId, 1); }, 1000); }, - function (error) { + function(error) { NVRDataModel.debug("Error in neighbor call " + JSON.stringify(error)); }); @@ -1416,7 +1399,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.humanizeTime = "..."; $scope.mName = "..."; $http.get(myurl) - .then(function (success) { + .then(function(success) { // console.log ("DUCCESS::"+JSON.stringify(success)); @@ -1454,11 +1437,11 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro neighborEvents(event.Event.Id) - .then(function (success) { + .then(function(success) { $scope.nextId = success.next; $scope.prevId = success.prev; }, - function (error) { + function(error) { //console.log(JSON.stringify(error)); }); @@ -1471,17 +1454,17 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro event.Event.video = {}; var videoURL; - if ((event.Event.imageMode == 'path') || NVRDataModel.getLogin().forceImageModePath ) + if ((event.Event.imageMode == 'path') || NVRDataModel.getLogin().forceImageModePath) videoURL = event.Event.baseURL + "/events/" + event.Event.relativePath + event.Event.DefaultVideo; else videoURL = event.Event.baseURL + "/index.php?view=view_video&eid=" + event.Event.Id; // hack - //videoURL = "http://static.videogular.com/assets/videos/videogular.mp4"; - //videoURL = "http://arjunrc.ddns.net:8888/foo2.mp4"; + //videoURL = "http://static.videogular.com/assets/videos/videogular.mp4"; + //videoURL = "http://arjunrc.ddns.net:8888/foo2.mp4"; $scope.video_url = videoURL; - // console.log("************** VIDEO IS " + videoURL); + console.log("************** VIDEO IS " + videoURL); NVRDataModel.debug("Video url passed to player is: " + videoURL); @@ -1489,16 +1472,15 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("************** VIDEO IS " + videoURL); - + $scope.videoObject = { config: { autoPlay: true, - responsive:false, - nativeControls:false, - - playsInline:true, - sources: [ - { + responsive: false, + nativeControls: false, + + playsInline: true, + sources: [{ src: $sce.trustAsResourceUrl(videoURL), type: "video/mp4" } @@ -1530,7 +1512,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro realtime: true, step: 1, className: "mySliderClass", - callback: function (value, released) { + callback: function(value, released) { //console.log("CALLBACK"+value+released); $ionicScrollDelegate.freezeScroll(!released); @@ -1606,11 +1588,16 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.totalEventTime = Math.round(parseFloat(event.Event.Length)) - 1; $scope.currentEventTime = 0; - $timeout(function () { - drawGraph(); - }, 500); + // video mode doesn't need this graph - it won't really work + if ($scope.defaultVideo == undefined || $scope.defaultVideo == '') { + $timeout(function() { + drawGraph(); + }, 500); + } + + }, - function (err) { + function(err) { NVRDataModel.log("Error retrieving detailed frame API " + JSON.stringify(err)); NVRDataModel.displayBanner('error', ['could not retrieve frame details', 'please try again']); }); @@ -1620,7 +1607,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro if (typeof $scope.ionRange !== 'undefined') { - $scope.$watch('ionRange.index', function () { + $scope.$watch('ionRange.index', function() { // $scope.mycarousel.index = parseInt($scope.ionRange.index) - 1; @@ -1633,7 +1620,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } if (typeof $scope.mycarousel !== 'undefined') { - $scope.$watch('mycarousel.index', function () { + $scope.$watch('mycarousel.index', function() { if (currentEvent && $scope.ionRange.index == parseInt(currentEvent.Event.Frames - 1)) { playbackFinished(); @@ -1679,4 +1666,4 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro -}]); \ No newline at end of file +}]); -- cgit v1.2.3 From 31ca68739126f5740681238539a8c6a1b66e0000 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 18 Nov 2016 09:28:08 -0500 Subject: mass formatting and normalization - tweaked JSBeautify options --- www/js/EventModalCtrl.js | 771 +++++++++++++++++++++++++++-------------------- 1 file changed, 439 insertions(+), 332 deletions(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 9067bd0e..5773c5ef 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -3,11 +3,8 @@ /* jslint browser: true*/ /* global saveAs, cordova,StatusBar,angular,console,ionic, moment, Chart */ - - - -angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', 'SecuredPopups', function($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter, SecuredPopups) { - +angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', 'SecuredPopups', function($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter, SecuredPopups) +{ // from parent scope var currentEvent = $scope.currentEvent; @@ -17,11 +14,11 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.currentRate = '-'; var timeFormat = 'MM/DD/YYYY HH:mm:ss'; - var framearray = { labels: [], - datasets: [{ + datasets: [ + { //label: '# of Votes', backgroundColor: 'rgba(242, 12, 12, 0.5)', borderColor: 'rgba(242, 12, 12, 0.5)', @@ -31,7 +28,6 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var frameoptions = []; - var eventImageDigits = 5; // failsafe $scope.currentProgress = { progress: 0 @@ -40,7 +36,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro progress: 0 }; NVRDataModel.getKeyConfigParams(0) - .then(function(data) { + .then(function(data) + { //console.log ("***GETKEY: " + JSON.stringify(data)); eventImageDigits = parseInt(data); NVRDataModel.log("Image padding digits reported as " + eventImageDigits); @@ -54,8 +51,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.showModalRangeSider = false; $scope.isModalActive = true; - - $timeout(function() { + $timeout(function() + { $scope.showModalRangeSider = true; }, 2000); @@ -64,7 +61,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro document.addEventListener("resume", onResume, false); $rootScope.authSession = "undefined"; - $ionicLoading.show({ + $ionicLoading.show( + { template: $translate.instant('kNegotiatingStreamAuth'), animation: 'fade-in', showBackdrop: true, @@ -74,27 +72,25 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); var ld = NVRDataModel.getLogin(); - $scope.currentStreamMode = ld.gapless ? 'gapless' : 'single'; NVRDataModel.log("Using stream mode " + $scope.currentStreamMode); NVRDataModel.debug("EventModalCtrl called from " + $ionicHistory.currentStateName()); // This is not needed for event mode - - NVRDataModel.debug("Setting playback to " + $scope.streamMode); - $rootScope.validMonitorId = $scope.monitors[0].Monitor.Id; NVRDataModel.getAuthKey($rootScope.validMonitorId, (Math.floor((Math.random() * 999999) + 1)).toString()) - .then(function(success) { + .then(function(success) + { $ionicLoading.hide(); $rootScope.authSession = success; NVRDataModel.log("Modal: Stream authentication construction: " + $rootScope.authSession); }, - function(error) { + function(error) + { $ionicLoading.hide(); NVRDataModel.debug("ModalCtrl: Error details of stream auth:" + error); @@ -102,20 +98,22 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.log("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); }); - - //-------------------------------------------------------------------------------------- // Handles bandwidth change, if required // //-------------------------------------------------------------------------------------- - $rootScope.$on("bandwidth-change", function(e, data) { + $rootScope.$on("bandwidth-change", function(e, data) + { // not called for offline, I'm only interested in BW switches NVRDataModel.debug("Got network change:" + data); var ds; - if (data == 'lowbw') { + if (data == 'lowbw') + { ds = $translate.instant('kLowBWDisplay'); - } else { + } + else + { ds = $translate.instant('kHighBWDisplay'); } NVRDataModel.displayBanner('net', [ds]); @@ -125,78 +123,80 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.singleImageQuality = (NVRDataModel.getBandwidth() == "lowbw") ? zm.eventSingleImageQualityLowBW : ld.singleImageQuality; }); - - - //------------------------------------------------------- // we use this to reload the connkey if authkey changed //------------------------------------------------------ - - $rootScope.$on("auth-success", function() { + $rootScope.$on("auth-success", function() + { NVRDataModel.debug("EventModalCtrl: Re-login detected, resetting everything & re-generating connkey"); NVRDataModel.stopNetwork("Auth-Success inside EventModalCtrl"); $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); //console.log ("********* OFFSET FROM AUTH SUCC"); - $timeout(function() { + $timeout(function() + { sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); }, 500); //$timeout.cancel(eventQueryHandle); //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); - - }); //------------------------------------------------------- // tap to pause //------------------------------------------------------ - $scope.togglePause = function() { + $scope.togglePause = function() + { $scope.isPaused = !$scope.isPaused; NVRDataModel.debug("Paused is " + $scope.isPaused); - - sendCommand($scope.isPaused ? '1' : '2', $scope.connKey); }; - - $scope.onPlayerReady = function(handle) { + $scope.onPlayerReady = function(handle) + { // we need this timeout to avoid load interrupting // play -- I suppose its an angular digest foo thing NVRDataModel.debug("Player is ready"); - $timeout(function() { handle.play(); }, 400); + $timeout(function() + { + handle.play(); + }, 400); // window.stop(); }; - $scope.onCanPlay = function() { + $scope.onCanPlay = function() + { NVRDataModel.debug("This video can be played"); }; - $scope.onVideoError = function(event) { + $scope.onVideoError = function(event) + { if (!$scope.isModalActive) return; NVRDataModel.debug("player reported a video error:" + JSON.stringify(event)); - $rootScope.zmPopup = SecuredPopups.show('alert', { + $rootScope.zmPopup = SecuredPopups.show('alert', + { title: $translate.instant('kError'), template: $rootScope.platformOS == 'desktop' ? $translate.instant('kVideoError') : $translate.instant('kVideoErrorMobile') }); }; - //------------------------------------------------------- // This is what we call every zm.EventQueryInterval // it really only queries to get status to it can display // zms takes care of the display //------------------------------------------------------ - function checkEvent() { + function checkEvent() + { - if ($scope.modalFromTimelineIsOpen == false) { + if ($scope.modalFromTimelineIsOpen == false) + { NVRDataModel.log("Modal was closed in timeline, cancelling timer"); $interval.cancel(eventQueryHandle); return; @@ -205,45 +205,51 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log ("Event timer"); //console.log ("Event timer"); $scope.checkEventOn = true; - if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { + if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') + { //console.log("playing video, not using zms, skipping event commands"); - } else { + } + else + { processEvent('99', $scope.connKey); } } - - function sendCommand(cmd, connkey, extras, rq) { + function sendCommand(cmd, connkey, extras, rq) + { var d = $q.defer(); - if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { + if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') + { // console.log("playing video, not using zms, skipping event commands"); d.resolve(true); return (d.promise); } - - var loginData = NVRDataModel.getLogin(); //console.log("Sending CGI command to " + loginData.url); var rqtoken = rq ? rq : "stream"; var myauthtoken = $rootScope.authSession.replace("&auth=", ""); //&auth= - $http({ + $http( + { method: 'POST', /*timeout: 15000,*/ url: loginData.url + '/index.php', - headers: { + headers: + { 'Content-Type': 'application/x-www-form-urlencoded', //'Accept': '*/*', }, - transformRequest: function(obj) { + transformRequest: function(obj) + { var str = []; for (var p in obj) str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); var foo = str.join("&"); - if (extras) { + if (extras) + { foo = foo + extras; //console.log("EXTRAS****SUB RETURNING " + foo); } @@ -252,7 +258,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }, - data: { + data: + { view: "request", request: rqtoken, connkey: connkey, @@ -262,14 +269,15 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // pass: loginData.password } }) - .then(function(resp) { + .then(function(resp) + { NVRDataModel.debug("sendCmd response:" + JSON.stringify(resp)); d.resolve(resp); return (d.promise); - }, - function(resp) { + function(resp) + { NVRDataModel.debug("sendCmd error:" + JSON.stringify(resp)); d.reject(resp); return (d.promise); @@ -278,10 +286,11 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro return (d.promise); } + function processEvent(cmd, connkey) + { - function processEvent(cmd, connkey) { - - if ($scope.blockSlider) { + if ($scope.blockSlider) + { //console.log("Not doing ZMS Command as slider is depressed..."); return; } @@ -290,15 +299,18 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("sending process Event command to " + loginData.url); var myauthtoken = $rootScope.authSession.replace("&auth=", ""); //&auth= - var req = $http({ + var req = $http( + { method: 'POST', /*timeout: 15000,*/ url: loginData.url + '/index.php', - headers: { + headers: + { 'Content-Type': 'application/x-www-form-urlencoded', //'Accept': '*/*', }, - transformRequest: function(obj) { + transformRequest: function(obj) + { var str = []; for (var p in obj) str.push(encodeURIComponent(p) + "=" + @@ -308,7 +320,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro return foo; }, - data: { + data: + { view: "request", request: "stream", connkey: connkey, @@ -319,17 +332,18 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } }); - req.success(function(resp) { + req.success(function(resp) + { // NVRDataModel.debug ("processEvent success:"+JSON.stringify(resp)); - if (resp.result == "Ok") { + if (resp.result == "Ok") + { $scope.currentProgress.progress = resp.status.progress; $scope.eventId = resp.status.event; $scope.d_eventId = $scope.eventId; $scope.currentRate = resp.status.rate; - if ($scope.currentProgress.progress > $scope.currentEventDuration) $scope.currentProgress.progress = $scope.currentEventDuration; $scope.progressText = "At " + $scope.currentProgress.progress + "s of " + $scope.currentEventDuration + "s"; @@ -339,12 +353,11 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // as this code conflicts with fast rev etc //if (Math.floor(resp.status.progress) >=$scope.currentEventDuration) - - //$timeout (checkEvent(), zm.eventPlaybackQuery); //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); - } else // resp.result was messed up + } + else // resp.result was messed up { NVRDataModel.debug("Hmm I found an error " + JSON.stringify(resp)); @@ -352,7 +365,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); // console.log (JSON.stringify(resp)); - $timeout(function() { + $timeout(function() + { sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); }, 500); NVRDataModel.debug("so I'm regenerating Connkey to " + $scope.connKey); @@ -360,8 +374,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } }); - - req.error(function(resp) { + req.error(function(resp) + { NVRDataModel.debug("processEvent error:" + JSON.stringify(resp)); //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); @@ -369,9 +383,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - - - function onPause() { + function onPause() + { // $interval.cancel(modalIntervalHandle); @@ -381,53 +394,50 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - - function onResume() { + function onResume() + { NVRDataModel.debug("EventModalCtrl: Modal resume called"); - - $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); } - - - - - - - - $scope.finishedLoadingImage = function() { + $scope.finishedLoadingImage = function() + { // console.log("***Monitor image FINISHED Loading***"); $ionicLoading.hide(); }; - $scope.enableSliderBlock = function() { + $scope.enableSliderBlock = function() + { $scope.blockSlider = true; }; - $scope.youChangedSlider = function() { + $scope.youChangedSlider = function() + { //console.log("YOU changed " + $scope.sliderProgress.progress); $scope.currentProgress.progress = $scope.sliderProgress.progress; sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress) - .then(function(s) { $scope.blockSlider = false; }, function(e) { $scope.blockSlider = false; }); - + .then(function(s) + { + $scope.blockSlider = false; + }, function(e) + { + $scope.blockSlider = false; + }); }; - - - - //----------------------------------------------------------------------- // Sucess/Error handlers for saving a snapshot of the // monitor image to phone storage //----------------------------------------------------------------------- - function SaveSuccess() { - $ionicLoading.show({ + function SaveSuccess() + { + $ionicLoading.show( + { template: $translate.instant('kDone'), noBackdrop: true, duration: 1000 @@ -435,8 +445,10 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.debug("ModalCtrl:Photo saved successfuly"); } - function SaveError(e) { - $ionicLoading.show({ + function SaveError(e) + { + $ionicLoading.show( + { template: $translate.instant('kErrorSave'), noBackdrop: true, duration: 2000 @@ -445,21 +457,20 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("***ERROR"); } - - $scope.jumpToOffsetInEvent = function() { + $scope.jumpToOffsetInEvent = function() + { // streamReq.send( streamParms+"&command="+CMD_SEEK+"&offset="+offset ); }; - - //----------------------------------------------------------------------- // Saves a snapshot of the monitor image to phone storage //----------------------------------------------------------------------- + $scope.saveEventImageToPhoneWithPerms = function(onlyAlarms) + { - $scope.saveEventImageToPhoneWithPerms = function(onlyAlarms) { - - if ($rootScope.platformOS != 'android') { + if ($rootScope.platformOS != 'android') + { processSaveEventImageToPhone(onlyAlarms); return; } @@ -469,51 +480,59 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var permissions = cordova.plugins.permissions; permissions.hasPermission(permissions.WRITE_EXTERNAL_STORAGE, checkPermissionCallback, null); - function checkPermissionCallback(status) { - if (!status.hasPermission) { + function checkPermissionCallback(status) + { + if (!status.hasPermission) + { SaveError("No permission to write to external storage"); } permissions.requestPermission(permissions.WRITE_EXTERNAL_STORAGE, succ, err); } - function succ(s) { + function succ(s) + { processSaveEventImageToPhone(onlyAlarms); } - function err(e) { + function err(e) + { SaveError("Error in requestPermission"); } }; + function processSaveEventImageToPhone(onlyAlarms) + { - function processSaveEventImageToPhone(onlyAlarms) { - - if ($scope.loginData.useNphZmsForEvents) { + if ($scope.loginData.useNphZmsForEvents) + { NVRDataModel.log("Use ZMS stream to save to phone"); saveEventImageToPhoneZms(onlyAlarms); - - } else { + } + else + { saveEventImageToPhone(onlyAlarms); } - } - function saveEventImageToPhoneZms(onlyAlarms) { + function saveEventImageToPhoneZms(onlyAlarms) + { // The strategy here is to build the array now so we can grab frames // $scope.currentProgress.progress is the seconds where we are // $scope.eventId is the event Id $scope.isPaused = true; - $ionicLoading.show({ + $ionicLoading.show( + { template: $translate.instant('kPleaseWait'), noBackdrop: true, duration: zm.httpTimeout }); sendCommand('1', $scope.connKey). - then(function(resp) { + then(function(resp) + { // console.log ("PAUSE ANSWER IS " + JSON.stringify(resp)); $scope.currentProgress.progress = resp.data.status.progress; @@ -523,7 +542,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var apiurl = $scope.loginData.apiurl + "/events/" + $scope.eventId + ".json"; NVRDataModel.debug("prepared to get frame details using " + apiurl); $http.get(apiurl) - .then(function(success) { + .then(function(success) + { var event = success.data.event; @@ -549,23 +569,29 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.mycarousel.index = myFrame; // console.log ("STEP 1 : Computed index as "+ $scope.mycarousel.index); var i; - for (i = 1; i <= event.Frame.length; i++) { + for (i = 1; i <= event.Frame.length; i++) + { var fname = padToN(event.Frame[i - 1].FrameId, eventImageDigits) + "-capture.jpg"; // console.log ("Building " + fname); // console.log ("DUMPING ONE " + JSON.stringify(event.Frame[i-1])); // onlyAlarms means only copy alarmed frames - if (onlyAlarms) { - if (event.Frame[i - 1] && event.Frame[i - 1].Type == 'Alarm') { - $scope.slides.push({ + if (onlyAlarms) + { + if (event.Frame[i - 1] && event.Frame[i - 1].Type == 'Alarm') + { + $scope.slides.push( + { id: event.Frame[i - 1].FrameId, img: fname, }); //console.log ("ALARM PUSHED " + fname); } - } else // push all frames + } + else // push all frames { - $scope.slides.push({ + $scope.slides.push( + { id: event.Frame[i - 1].FrameId, img: fname, }); @@ -577,13 +603,14 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $ionicLoading.hide(); saveEventImageToPhone(onlyAlarms); - }, - function(err) { + function(err) + { $ionicLoading.hide(); NVRDataModel.log("snapshot API Error: Could not get frames " + JSON.stringify(err)); - $ionicLoading.show({ + $ionicLoading.show( + { template: $translate.instant('kErrorRetrievingFrames'), noBackdrop: true, duration: 4000 @@ -591,18 +618,18 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); }, - function(err) { + function(err) + { NVRDataModel.debug("Error pausing stream before snapshot " + JSON.stringify(err)); $ionicLoading.hide(); } ); // then - } - - function saveEventImageToPhone(onlyAlarms) { + function saveEventImageToPhone(onlyAlarms) + { var curState = carouselUtils.getStop(); carouselUtils.setStop(true); @@ -613,30 +640,30 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var canvas, context, imageDataUrl, imageData; var loginData = NVRDataModel.getLogin(); - // for alarms only if (onlyAlarms) $scope.mycarousel.index = 0; var url = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.mycarousel.index].img; - $scope.selectEventUrl = url; $scope.slideIndex = $scope.mycarousel.index; $scope.slideLastIndex = $scope.slides.length - 1; // console.log ("URL TO DISPLAY " + url); - - $rootScope.zmPopup = $ionicPopup.show({ + $rootScope.zmPopup = $ionicPopup.show( + { template: '
Frame: {{slideIndex+1}} / {{slideLastIndex+1}}

', title: 'Select ' + (onlyAlarms ? 'Alarmed ' : '') + 'frame to save', subTitle: 'use left and right arrows to change', scope: $scope, cssClass: 'popup95', - buttons: [{ + buttons: [ + { // left 1 text: '', type: 'button-small button-energized ion-chevron-left', - onTap: function(e) { + onTap: function(e) + { if ($scope.slideIndex > 0) $scope.slideIndex--; $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img; //NVRDataModel.log("selected frame is " + $scope.slideIndex); @@ -645,22 +672,26 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro e.preventDefault(); } - }, { + }, + { // right 1 text: '', type: 'button-small button-energized ion-chevron-right', - onTap: function(e) { + onTap: function(e) + { if ($scope.slideIndex < $scope.slideLastIndex) $scope.slideIndex++; $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img; //NVRDataModel.log("selected frame is " + $scope.slideIndex); console.log("URL TO DISPLAY " + $scope.slides[$scope.slideIndex].img); e.preventDefault(); } - }, { + }, + { // left 10 text: '', type: 'button-small button-energized ion-skip-backward', - onTap: function(e) { + onTap: function(e) + { var tempVar = $scope.slideIndex; tempVar -= 10; if (tempVar < 0) tempVar = 0; @@ -671,11 +702,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro e.preventDefault(); } - }, { + }, + { // right 10 text: '', type: 'button-small button-energized ion-skip-forward', - onTap: function(e) { + onTap: function(e) + { var tempVar = $scope.slideIndex; tempVar += 10; if (tempVar > $scope.slideLastIndex) tempVar = $scope.slideLastIndex; @@ -690,10 +723,12 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro { text: '', type: 'button-assertive button-small ion-close-round' - }, { + }, + { text: '', type: 'button-positive button-small ion-checkmark-round', - onTap: function(e) { + onTap: function(e) + { saveNow(); } @@ -701,8 +736,10 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro ] }); - function saveNow() { - $ionicLoading.show({ + function saveNow() + { + $ionicLoading.show( + { template: $translate.instant('kSavingSnapshot') + "...", noBackdrop: true, duration: zm.httpTimeout @@ -711,7 +748,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.log("saveNow: File path to grab is " + url); var img = new Image(); - img.onload = function() { + img.onload = function() + { // console.log("********* ONLOAD"); canvas = document.createElement('canvas'); canvas.width = img.width; @@ -722,8 +760,10 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro imageDataUrl = canvas.toDataURL('image/jpeg', 1.0); imageData = imageDataUrl.replace(/data:image\/jpeg;base64,/, ''); - if ($rootScope.platformOS != "desktop") { - try { + if ($rootScope.platformOS != "desktop") + { + try + { cordova.exec( SaveSuccess, @@ -732,54 +772,62 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro 'saveImageDataToLibrary', [imageData] ); // carouselUtils.setStop(curState); - } catch (e) { + } + catch (e) + { SaveError(e.message); // carouselUtils.setStop(curState); } - } else { - + } + else + { var fname = $scope.relativePath + $scope.slides[$scope.slideIndex].img + ".png"; fname = fname.replace(/\//, "-"); fname = fname.replace(/\.jpg/, ''); - canvas.toBlob(function(blob) { + canvas.toBlob(function(blob) + { saveAs(blob, fname); SaveSuccess(); }); } }; - try { + try + { img.src = url; // console.log ("SAVING IMAGE SOURCE"); - } catch (e) { + } + catch (e) + { SaveError(e.message); } } } - - $scope.reloadView = function() { + $scope.reloadView = function() + { NVRDataModel.log("Reloading view for modal view, recomputing rand"); $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); $scope.isModalActive = true; }; - $scope.scaleImage = function() { + $scope.scaleImage = function() + { $scope.imageFit = !$scope.imageFit; console.log("Switching image style to " + $scope.imageFit); }; - $scope.$on('$ionicView.enter', function() { + $scope.$on('$ionicView.enter', function() + { //console.log (">>>>>>>>>>>>>>>>>>>> MODAL VIEW ENTER"); - - }); - $scope.$on('modal.shown', function(e, m) { + $scope.$on('modal.shown', function(e, m) + { if (m.id != 'footage') @@ -795,8 +843,6 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.checkEventOn = false; //$scope.singleImageQuality = 100; - - //$scope.commandURL = $scope.currentEvent.Event.baseURL+"/index.php"; // NVRDataModel.log (">>>>>>>>>>>>>>>>>>ZMS url command is " + $scope.commandURL); @@ -811,23 +857,30 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log ("CURRENT EVENT " + JSON.stringify($scope.currentEvent)); $scope.currentEventDuration = Math.floor($scope.currentEvent.Event.Length); //console.log ($scope.event.Event.Frames); - if (currentEvent && currentEvent.Event) { + if (currentEvent && currentEvent.Event) + { //console.log ("************ CALLING PREPARE MODAL ***********"); prepareModalEvent(currentEvent.Event.Id); - if (ld.useNphZmsForEvents) { - $timeout(function() { + if (ld.useNphZmsForEvents) + { + $timeout(function() + { - if ($scope.modal != undefined && $scope.modal.isShown()) { + if ($scope.modal != undefined && $scope.modal.isShown()) + { NVRDataModel.log(">>>Starting checkAllEvents interval..."); //eventQueryHandle = $timeout (checkEvent(), zm.eventPlaybackQuery); $interval.cancel(eventQueryHandle); - eventQueryHandle = $interval(function() { + eventQueryHandle = $interval(function() + { checkEvent(); // console.log ("Refreshing Image..."); }.bind(this), (NVRDataModel.getBandwidth() == "lowbw") ? zm.eventPlaybackQueryLowBW : zm.eventPlaybackQuery); - } else { + } + else + { NVRDataModel.log(">>>Modal was exited, not starting checkAllEvents"); } @@ -836,51 +889,53 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - - - - - }); //var current_data; - function drawGraph() { - + function drawGraph() + { var cv = document.getElementById("eventchart"); var ctx = cv.getContext("2d"); - frameoptions = { responsive: true, legend: false, - title: { + title: + { display: false, text: "" }, - scales: { - yAxes: [{ + scales: + { + yAxes: [ + { display: false, - scaleLabel: { + scaleLabel: + { display: false, labelString: 'value', } }], - xAxes: [{ + xAxes: [ + { type: 'time', display: false, - time: { + time: + { format: timeFormat, tooltipFormat: 'll HH:mm', min: framearray.datasets[0].data[0].x, max: framearray.datasets[0].data[framearray.datasets[0].data.length - 1].x, - displayFormats: { + displayFormats: + { } }, - scaleLabel: { + scaleLabel: + { display: false, labelString: '' } @@ -889,11 +944,11 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } }; + $timeout(function() + { - $timeout(function() { - - - var myChart = new Chart(ctx, { + var myChart = new Chart(ctx, + { type: 'line', data: framearray, options: frameoptions, @@ -902,12 +957,16 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); } - $scope.videoTime = function(s, c) { + $scope.videoTime = function(s, c) + { var a, o; - if (NVRDataModel.getLogin().useLocalTimeZone) { + if (NVRDataModel.getLogin().useLocalTimeZone) + { a = moment.tz(s, NVRDataModel.getTimeZoneNow()).tz(moment.tz.guess()); - } else { + } + else + { a = moment(s); } a.add(c); @@ -918,13 +977,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }; - $scope.$on('modal.removed', function(e, m) { + $scope.$on('modal.removed', function(e, m) + { console.log("************* REMOVE CALLED"); $interval.cancel(eventQueryHandle); if (m.id != 'footage') return; - $scope.isModalActive = false; NVRDataModel.debug("Modal removed - killing connkey"); @@ -934,13 +993,15 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // Execute action }); - // Playback speed adjuster - $scope.adjustSpeed = function(val) { + $scope.adjustSpeed = function(val) + { - if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { + if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') + { - $ionicLoading.show({ + $ionicLoading.show( + { template: $translate.instant('kUseVideoControls'), noBackdrop: true, duration: 3000 @@ -950,11 +1011,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var ld = NVRDataModel.getLogin(); - if (ld.useNphZmsForEvents) { + if (ld.useNphZmsForEvents) + { var cmd; $scope.isPaused = false; - switch (val) { + switch (val) + { case 'ff': cmd = 4; break; @@ -972,28 +1035,32 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro cmd = 0; } - $ionicLoading.show({ + $ionicLoading.show( + { template: $translate.instant('kPleaseWait') + "...", noBackdrop: true, duration: zm.httpTimeout }); sendCommand(cmd, $scope.connKey) - .then(function(success) { + .then(function(success) + { $ionicLoading.hide(); }, - function(err) { + function(err) + { $ionicLoading.hide(); NVRDataModel.debug("Error in adjust speed: " + JSON.stringify(err)); } ); - - } else // not using nph + } + else // not using nph { - switch (val) { + switch (val) + { case "super": $scope.eventSpeed = 20 / $scope.event.Event.Frames; @@ -1021,7 +1088,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } NVRDataModel.debug("Set playback speed to " + $scope.eventSpeed); - $ionicLoading.show({ + $ionicLoading.show( + { template: $translate.instant('kPlaybackInterval') + ': ' + $scope.eventSpeed.toFixed(3) + "ms", animation: 'fade-in', showBackdrop: false, @@ -1031,12 +1099,10 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); } - - }; - - $scope.toggleGapless = function() { + $scope.toggleGapless = function() + { // console.log(">>>>>>>>>>>>>>GAPLESS TOGGLE INSIDE MODAL"); $scope.loginData.gapless = !$scope.loginData.gapless; NVRDataModel.setLogin($scope.loginData); @@ -1046,18 +1112,18 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.debug("Regenerating connkey as gapless has changed"); // console.log ("********* OFFSET FROM TOGGLE GAPLESS"); $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); - $timeout(function() { + $timeout(function() + { sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); }, 500); //$timeout.cancel(eventQueryHandle); //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); - }; - // This function returns neighbor events if applicable - function neighborEvents(eid) { + function neighborEvents(eid) + { var d = $q.defer(); // now get event details to show alarm frames var loginData = NVRDataModel.getLogin(); @@ -1067,7 +1133,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro next: "" }; $http.get(myurl) - .success(function(data) { + .success(function(data) + { // In Timeline view, gapless should stick to the same monitor if ($scope.followSameMonitor == "1") // we are viewing only one monitor @@ -1075,90 +1142,101 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.debug("Getting next event for same monitor Id "); neighbors.prev = data.event.Event.PrevOfMonitor ? data.event.Event.PrevOfMonitor : ""; neighbors.next = data.event.Event.NextOfMonitor ? data.event.Event.NextOfMonitor : ""; - } else { + } + else + { neighbors.prev = data.event.Event.Prev ? data.event.Event.Prev : ""; neighbors.next = data.event.Event.Next ? data.event.Event.Next : ""; } NVRDataModel.debug("Neighbor events of " + eid + "are Prev:" + neighbors.prev + " and Next:" + neighbors.next); - d.resolve(neighbors); return (d.promise); }) - .error(function(err) { + .error(function(err) + { NVRDataModel.log("Error retrieving neighbors" + JSON.stringify(err)); d.reject(neighbors); return (d.promise); - }); return (d.promise); } - - $scope.zoomImage = function(val) { + $scope.zoomImage = function(val) + { var zl = parseInt($ionicScrollDelegate.$getByHandle("imgscroll").getScrollPosition().zoom); - if (zl == 1 && val == -1) { + if (zl == 1 && val == -1) + { NVRDataModel.debug("Already zoomed out max"); return; } - zl += val; NVRDataModel.debug("Zoom level is " + zl); $ionicScrollDelegate.$getByHandle("imgscroll").zoomTo(zl, true); }; - //-------------------------------------------------------- //Navigate to next/prev event in full screen mode //-------------------------------------------------------- - $scope.onSwipeEvent = function(eid, dirn) { + $scope.onSwipeEvent = function(eid, dirn) + { //console.log("HERE"); var ld = NVRDataModel.getLogin(); if (!ld.canSwipeMonitors) return; - if ($ionicScrollDelegate.$getByHandle("imgscroll").getScrollPosition().zoom != 1) { + if ($ionicScrollDelegate.$getByHandle("imgscroll").getScrollPosition().zoom != 1) + { //console.log("Image is zoomed in - not honoring swipe"); return; } - if (ld.useNphZmsForEvents) { + if (ld.useNphZmsForEvents) + { NVRDataModel.log("using zms to move "); jumpToEventZms($scope.connKey, dirn); // sendCommand ( dirn==1?'13':'12',$scope.connKey); - } else { + } + else + { jumpToEvent(eid, dirn); } //console.log("JUMPING"); - }; - $scope.jumpToEvent = function(eid, dirn) { + $scope.jumpToEvent = function(eid, dirn) + { // console.log("jumptoevent"); var ld = NVRDataModel.getLogin(); - if (ld.useNphZmsForEvents) { + if (ld.useNphZmsForEvents) + { NVRDataModel.log("using zms to move "); jumpToEventZms($scope.connKey, dirn); // sendCommand ( dirn==1?'13':'12',$scope.connKey); - } else { + } + else + { jumpToEvent(eid, dirn); } }; - function jumpToEvent(eid, dirn) { + function jumpToEvent(eid, dirn) + { NVRDataModel.log("Event jump called with:" + eid); - if (eid == "") { - $ionicLoading.show({ + if (eid == "") + { + $ionicLoading.show( + { template: $translate.instant('kNoMoreEvents'), noBackdrop: true, duration: 2000 @@ -1169,26 +1247,29 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var slidein; var slideout; - if (dirn == 1) { + if (dirn == 1) + { slideout = "animated slideOutLeft"; slidein = "animated slideInRight"; - } else { + } + else + { slideout = "animated slideOutRight"; slidein = "animated slideInLeft"; } var element = angular.element(document.getElementById("full-screen-event")); element.addClass(slideout).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', outWithOld); - - - function outWithOld() { + function outWithOld() + { NVRDataModel.log("ModalCtrl:Stopping network pull..."); NVRDataModel.stopNetwork("EventModalCtrl-out with old"); $scope.animationInProgress = true; // give digest time for image to swap // 100 should be enough - $timeout(function() { + $timeout(function() + { element.removeClass(slideout); element.addClass(slidein) .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', inWithNew); @@ -1196,7 +1277,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }, 200); } - function inWithNew() { + function inWithNew() + { element.removeClass(slidein); $scope.animationInProgress = false; carouselUtils.setStop(false); @@ -1204,7 +1286,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - function humanizeTime(str) { + function humanizeTime(str) + { // if (NVRDataModel.getLogin().useLocalTimeZone) return moment.tz(str, NVRDataModel.getTimeZoneNow()).fromNow(); // else @@ -1212,12 +1295,14 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - function jumpToEventZms(connkey, dirn) { + function jumpToEventZms(connkey, dirn) + { + if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') + { - if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { - - $ionicLoading.show({ + $ionicLoading.show( + { template: $translate.instant('kEventNavVidFeeds'), noBackdrop: true, duration: 3000 @@ -1229,7 +1314,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.d_eventId = "..."; NVRDataModel.debug("Sending " + cmd + " to " + connkey); - $ionicLoading.show({ + $ionicLoading.show( + { template: $translate.instant('kSwitchingEvents') + "...", noBackdrop: true, duration: zm.httpTimeout @@ -1238,17 +1324,20 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("Send command connkey: " + connkey); sendCommand(cmd, connkey) .then( - function(success) { + function(success) + { //console.log ("jump success " + JSON.stringify(success)); $ionicLoading.hide(); }, - function(error) { + function(error) + { NVRDataModel.debug("Hmm jump error " + JSON.stringify(error)); NVRDataModel.stopNetwork("EventModalCtrl-jumptoEventZms error"); $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); // console.log ("********* OFFSET FROM JUMPTOEVENTZMS ERROR"); - $timeout(function() { + $timeout(function() + { sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); }, 500); NVRDataModel.debug("so I'm regenerating Connkey to " + $scope.connKey); @@ -1258,23 +1347,24 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); var slidein; var slideout; - if (dirn == 1) { + if (dirn == 1) + { slideout = "animated slideOutLeft"; slidein = "animated slideInRight"; - } else { + } + else + { slideout = "animated slideOutRight"; slidein = "animated slideInLeft"; } var element = angular.element(document.getElementById("full-screen-event")); element.addClass(slideout).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', outWithOld); + function outWithOld() + { - - function outWithOld() { - - - - $timeout(function() { + $timeout(function() + { element.removeClass(slideout); element.addClass(slidein) .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', inWithNew); @@ -1282,20 +1372,20 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }, 200); } - function inWithNew() { + function inWithNew() + { element.removeClass(slidein); - } } - //-------------------------------------------------------- // utility function //-------------------------------------------------------- - function computeRelativePath(event) { + function computeRelativePath(event) + { var relativePath = ""; var loginData = NVRDataModel.getLogin(); var str = event.Event.StartTime; @@ -1320,7 +1410,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // utility function //-------------------------------------------------------- - function computeBasePath(event) { + function computeBasePath(event) + { var basePath = ""; var loginData = NVRDataModel.getLogin(); var str = event.Event.StartTime; @@ -1342,42 +1433,48 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro return basePath; } - //------------------------------------------------------------------------- // Called when rncarousel or video player finished playing event //------------------------------------------------------------------------- - $scope.playbackFinished = function() { + $scope.playbackFinished = function() + { playbackFinished(); }; - function playbackFinished() { + function playbackFinished() + { // currentEvent is updated with the currently playing event in prepareModalEvent() NVRDataModel.log("Playback of event " + currentEvent.Event.Id + " is finished"); - if ($scope.loginData.gapless) { + if ($scope.loginData.gapless) + { neighborEvents(currentEvent.Event.Id) - .then(function(success) { + .then(function(success) + { // lets give a second before gapless transition to the next event - $timeout(function() { + $timeout(function() + { $scope.nextId = success.next; $scope.prevId = success.prev; NVRDataModel.debug("Gapless move to event " + $scope.nextId); jumpToEvent($scope.nextId, 1); }, 1000); }, - function(error) { + function(error) + { NVRDataModel.debug("Error in neighbor call " + JSON.stringify(error)); }); - } else { + } + else + { NVRDataModel.debug("not going to next event, gapless is off"); } } - //-------------------------------------------------------- // Called by openModal as well as jump to event // what it basically does is get a detailed event API @@ -1387,10 +1484,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // API. Some parameters are repeated across both //-------------------------------------------------------- - - - - function prepareModalEvent(eid) { + function prepareModalEvent(eid) + { // Lets get the detailed event API var loginData = NVRDataModel.getLogin(); @@ -1399,8 +1494,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.humanizeTime = "..."; $scope.mName = "..."; $http.get(myurl) - .then(function(success) { - + .then(function(success) + { // console.log ("DUCCESS::"+JSON.stringify(success)); var event = success.data.event; @@ -1435,22 +1530,20 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("Event ID is " + $scope.eventId); //console.log("video is " + $scope.defaultVideo); - neighborEvents(event.Event.Id) - .then(function(success) { + .then(function(success) + { $scope.nextId = success.next; $scope.prevId = success.prev; }, - function(error) { + function(error) + { //console.log(JSON.stringify(error)); }); $scope.nextId = "..."; $scope.prevId = "..."; - - - event.Event.video = {}; var videoURL; @@ -1472,15 +1565,16 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("************** VIDEO IS " + videoURL); - $scope.videoObject = { - config: { + config: + { autoPlay: true, responsive: false, nativeControls: false, playsInline: true, - sources: [{ + sources: [ + { src: $sce.trustAsResourceUrl(videoURL), type: "video/mp4" } @@ -1512,31 +1606,38 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro realtime: true, step: 1, className: "mySliderClass", - callback: function(value, released) { + callback: function(value, released) + { //console.log("CALLBACK"+value+released); $ionicScrollDelegate.freezeScroll(!released); - }, //modelLabels:function(val) {return "";}, smooth: false, - css: { - background: { + css: + { + background: + { "background-color": "silver" }, - before: { + before: + { "background-color": "purple" }, - default: { + default: + { "background-color": "white" }, // default value: 1px - after: { + after: + { "background-color": "green" }, // zone after default value - pointer: { + pointer: + { "background-color": "red" }, // circle pointer - range: { + range: + { "background-color": "red" } // use it if double value }, @@ -1544,8 +1645,6 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }; - - $scope.mycarousel.index = 0; $scope.ionRange.index = 1; $scope.eventSpeed = $scope.event.Event.Length / $scope.event.Event.Frames; @@ -1553,16 +1652,17 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("**Resetting range"); $scope.slides = []; var i; - for (i = 1; i <= event.Event.Frames; i++) { + for (i = 1; i <= event.Event.Frames; i++) + { var fname = padToN(i, eventImageDigits) + "-capture.jpg"; // console.log ("Building " + fname); - $scope.slides.push({ + $scope.slides.push( + { id: i, img: fname }); } - // now get event details to show alarm frames //$scope.FrameArray = event.Frame; @@ -1571,65 +1671,72 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // lets framearray.datasets[0].data = []; - for (i = 0; i < event.Frame.length; i++) { + for (i = 0; i < event.Frame.length; i++) + { var ts = moment(event.Frame[i].TimeStamp).format(timeFormat); //console.log ("pushing s:" + event.Frame[i].Score+" t:"+ts); - framearray.datasets[0].data.push({ + framearray.datasets[0].data.push( + { x: ts, y: event.Frame[i].Score }); framearray.labels.push(""); - } $scope.totalEventTime = Math.round(parseFloat(event.Event.Length)) - 1; $scope.currentEventTime = 0; // video mode doesn't need this graph - it won't really work - if ($scope.defaultVideo == undefined || $scope.defaultVideo == '') { - $timeout(function() { + if ($scope.defaultVideo == undefined || $scope.defaultVideo == '') + { + $timeout(function() + { drawGraph(); }, 500); } - }, - function(err) { + function(err) + { NVRDataModel.log("Error retrieving detailed frame API " + JSON.stringify(err)); NVRDataModel.displayBanner('error', ['could not retrieve frame details', 'please try again']); }); - } - - if (typeof $scope.ionRange !== 'undefined') { - $scope.$watch('ionRange.index', function() { + if (typeof $scope.ionRange !== 'undefined') + { + $scope.$watch('ionRange.index', function() + { // $scope.mycarousel.index = parseInt($scope.ionRange.index) - 1; if (carouselUtils.getStop() == true) return; - //console.log ("***ION RANGE CHANGED TO " + $scope.mycarousel.index); }); } - if (typeof $scope.mycarousel !== 'undefined') { - $scope.$watch('mycarousel.index', function() { + if (typeof $scope.mycarousel !== 'undefined') + { + $scope.$watch('mycarousel.index', function() + { - if (currentEvent && $scope.ionRange.index == parseInt(currentEvent.Event.Frames - 1)) { + if (currentEvent && $scope.ionRange.index == parseInt(currentEvent.Event.Frames - 1)) + { playbackFinished(); } // end of playback from quick scrub // so ignore gapless - if ($scope.event && $scope.ionRange.index == parseInt($scope.event.Event.Frames) - 1) { - if (!$scope.modal || $scope.modal.isShown() == false) { + if ($scope.event && $scope.ionRange.index == parseInt($scope.event.Event.Frames) - 1) + { + if (!$scope.modal || $scope.modal.isShown() == false) + { // console.log("quick scrub playback over"); carouselUtils.setStop(true); $scope.ionRange.index = 0; @@ -1642,28 +1749,28 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.ionRange.index = ($scope.mycarousel.index + 1).toString(); // console.log ("***IONRANGE RANGE CHANGED TO " + $scope.ionRange.index); - }); } - function padToN(number, digits) { + function padToN(number, digits) + { var i; var stringMax = ""; var stringLeading = ""; - for (i = 1; i <= digits; i++) { + for (i = 1; i <= digits; i++) + { stringMax = stringMax + "9"; if (i != digits) stringLeading = stringLeading + "0"; } var numMax = parseInt(stringMax); - if (number <= numMax) { + if (number <= numMax) + { number = (stringLeading + number).slice(-digits); } //console.log ("PADTON: returning " + number); return number; } - - }]); -- cgit v1.2.3 From 76b17d856fe7ce6ccaa377e31a53a733920548df Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sat, 19 Nov 2016 17:02:36 -0500 Subject: added playback rate control 1,1.5,2x. #382 --- www/js/EventModalCtrl.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 5773c5ef..62609e5a 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -163,7 +163,9 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.debug("Player is ready"); $timeout(function() { + handle.setPlayback(2); handle.play(); + }, 400); // window.stop(); -- cgit v1.2.3 From fc9f5198166e500b85a217125157822a2f45921a Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 22 Nov 2016 11:03:03 -0400 Subject: Added cue points time matched with video player scrub bar #381 --- www/js/EventModalCtrl.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 62609e5a..544bf127 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -13,6 +13,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.loginData = NVRDataModel.getLogin(); $scope.currentRate = '-'; var timeFormat = 'MM/DD/YYYY HH:mm:ss'; + var event; + var gEvent; var framearray = { @@ -166,6 +168,25 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro handle.setPlayback(2); handle.play(); + // now set up cue points + NVRDataModel.debug("Setting cue points.."); + //console.log ("jEvent=" + JSON.stringify(currentEvent)); + //var event = $scope.currentEvent.event; + // console.log (JSON.stringify(event)); + var st = moment(currentEvent.Event.StartTime); + for (var l=0; l Date: Tue, 22 Nov 2016 12:25:58 -0400 Subject: tweaks to video loading display and other cleanup #381 --- www/js/EventModalCtrl.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 544bf127..67023fce 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -162,6 +162,14 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // we need this timeout to avoid load interrupting // play -- I suppose its an angular digest foo thing + + + + $ionicLoading.show( + { + template: "
" + $translate.instant('kVideoLoading')+"...", + + }); NVRDataModel.debug("Player is ready"); $timeout(function() { @@ -179,7 +187,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro if (currentEvent.Frame[l].Type=='Alarm') { var ft = moment(currentEvent.Frame[l].TimeStamp); - var s = st.diff(ft,'seconds'); + var s = Math.abs(st.diff(ft,'seconds')); //console.log("START="+currentEvent.Event.StartTime); //console.log("END="+currentEvent.Frame[l].TimeStamp); NVRDataModel.debug ("alarm cue at:"+s+"s"); @@ -194,11 +202,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.onCanPlay = function() { + $ionicLoading.hide(); NVRDataModel.debug("This video can be played"); }; $scope.onVideoError = function(event) { + $ionicLoading.hide(); if (!$scope.isModalActive) return; NVRDataModel.debug("player reported a video error:" + JSON.stringify(event)); $rootScope.zmPopup = SecuredPopups.show('alert', -- cgit v1.2.3 From 265e3e201e0d61c2c5c504354dd582f6128ef1e8 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 22 Nov 2016 13:58:25 -0400 Subject: currently hacked difference in time - computed a difference factor and multiplied it with all cues- so now cues are inside the player bar, but no idea if its accurate.#381 --- www/js/EventModalCtrl.js | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 67023fce..70943e49 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -15,6 +15,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var timeFormat = 'MM/DD/YYYY HH:mm:ss'; var event; var gEvent; + var handle; var framearray = { @@ -157,13 +158,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }; - $scope.onPlayerReady = function(handle) + $scope.onPlayerReady = function(api) { // we need this timeout to avoid load interrupting // play -- I suppose its an angular digest foo thing - + handle = api; $ionicLoading.show( { @@ -176,8 +177,26 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro handle.setPlayback(2); handle.play(); - // now set up cue points + }, 400); + + // window.stop(); + }; + + $scope.onCanPlay = function() + { + $ionicLoading.hide(); + NVRDataModel.debug("This video can be played"); + $scope.videoObject.config.cuepoints.points = []; + // now set up cue points NVRDataModel.debug("Setting cue points.."); + NVRDataModel.debug ("API-Total length:"+currentEvent.Event.Length); + + var vt1 = $filter('date')(handle.totalTime, "ss"); + + NVRDataModel.debug ("reported player length:"+vt1); + var factor = vt1/currentEvent.Event.Length; + NVRDataModel.debug ("hack - conversion factor:"+factor); + //NVRDataModel.debug ("Video-Total length left:"+handle.timeLeft); //console.log ("jEvent=" + JSON.stringify(currentEvent)); //var event = $scope.currentEvent.event; // console.log (JSON.stringify(event)); @@ -187,23 +206,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro if (currentEvent.Frame[l].Type=='Alarm') { var ft = moment(currentEvent.Frame[l].TimeStamp); - var s = Math.abs(st.diff(ft,'seconds')); + var s = factor*Math.abs(st.diff(ft,'seconds')); //console.log("START="+currentEvent.Event.StartTime); //console.log("END="+currentEvent.Frame[l].TimeStamp); NVRDataModel.debug ("alarm cue at:"+s+"s"); $scope.videoObject.config.cuepoints.points.push({time:s}); } } - - }, 400); - - // window.stop(); - }; - - $scope.onCanPlay = function() - { - $ionicLoading.hide(); - NVRDataModel.debug("This video can be played"); }; $scope.onVideoError = function(event) -- cgit v1.2.3 From 5eac484a44243b7d1a41036f4d25c4f23dcc6e76 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 22 Nov 2016 18:20:39 -0400 Subject: other video related updates --- www/js/EventModalCtrl.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 70943e49..7a66a506 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -163,7 +163,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // we need this timeout to avoid load interrupting // play -- I suppose its an angular digest foo thing - + console.log ("*********** ON PLAY READY"); handle = api; $ionicLoading.show( @@ -174,16 +174,18 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.debug("Player is ready"); $timeout(function() { - handle.setPlayback(2); - handle.play(); + handle.pause(); + handle.setPlayback(2); + handle.play(); - }, 400); + }, 300); // window.stop(); }; $scope.onCanPlay = function() { + console.log ("*********** CAN PLAY"); $ionicLoading.hide(); NVRDataModel.debug("This video can be played"); $scope.videoObject.config.cuepoints.points = []; -- cgit v1.2.3 From 2118c797762d6ef2699a80b2dc3356a6f10d0bae Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 23 Nov 2016 10:30:26 -0400 Subject: updates to make inline playback work on iOS --- www/js/EventModalCtrl.js | 1 + 1 file changed, 1 insertion(+) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 7a66a506..9a3730f7 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -1618,6 +1618,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro autoPlay: true, responsive: false, nativeControls: false, + nativeFullScreen:false, playsInline: true, sources: [ -- cgit v1.2.3 From 49f418657a63c744dd8ed6f12fd186f597a04759 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sun, 27 Nov 2016 13:08:13 -0500 Subject: fixes calculations for #395 - made it simpler, but it may exceed scrub bar --- www/js/EventModalCtrl.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 9a3730f7..e170fa09 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -193,22 +193,16 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro NVRDataModel.debug("Setting cue points.."); NVRDataModel.debug ("API-Total length:"+currentEvent.Event.Length); - var vt1 = $filter('date')(handle.totalTime, "ss"); - - NVRDataModel.debug ("reported player length:"+vt1); - var factor = vt1/currentEvent.Event.Length; - NVRDataModel.debug ("hack - conversion factor:"+factor); - //NVRDataModel.debug ("Video-Total length left:"+handle.timeLeft); - //console.log ("jEvent=" + JSON.stringify(currentEvent)); - //var event = $scope.currentEvent.event; - // console.log (JSON.stringify(event)); - var st = moment(currentEvent.Event.StartTime); + for (var l=0; l Date: Sun, 27 Nov 2016 13:44:17 -0500 Subject: added back player length in log #395 --- www/js/EventModalCtrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index e170fa09..f7030d12 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -192,7 +192,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // now set up cue points NVRDataModel.debug("Setting cue points.."); NVRDataModel.debug ("API-Total length:"+currentEvent.Event.Length); - + NVRDataModel.debug ("Player-Total length:"+handle.totalTime/1000); for (var l=0; l Date: Mon, 28 Nov 2016 14:03:13 -0500 Subject: modifications for picking up feeds from new zmNinja medium blog --- www/js/EventModalCtrl.js | 1 + 1 file changed, 1 insertion(+) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index f7030d12..81cf702a 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -185,6 +185,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.onCanPlay = function() { + console.log ("*********** CAN PLAY"); $ionicLoading.hide(); NVRDataModel.debug("This video can be played"); -- cgit v1.2.3 From 898d85ded3eb2260a80573bcc7c756c56d37bf15 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sat, 10 Dec 2016 08:27:27 -0500 Subject: added translations for buttons #410 --- www/js/EventModalCtrl.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'www/js/EventModalCtrl.js') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 81cf702a..c1633d1f 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -220,7 +220,9 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $rootScope.zmPopup = SecuredPopups.show('alert', { title: $translate.instant('kError'), - template: $rootScope.platformOS == 'desktop' ? $translate.instant('kVideoError') : $translate.instant('kVideoErrorMobile') + template: $rootScope.platformOS == 'desktop' ? $translate.instant('kVideoError') : $translate.instant('kVideoErrorMobile'), + okText: $translate.instant('kButtonOk'), + cancelText: $translate.instant('kButtonCancel'), }); }; -- cgit v1.2.3