diff options
| -rw-r--r-- | www/js/DataModel.js | 8 | ||||
| -rw-r--r-- | www/js/EventCtrl.js | 37 | ||||
| -rw-r--r-- | www/js/EventsGraphsCtrl.js | 13 | ||||
| -rw-r--r-- | www/js/HelpCtrl.js | 10 | ||||
| -rw-r--r-- | www/js/HttpFactory.js | 96 | ||||
| -rw-r--r-- | www/js/LoginCtrl.js | 14 | ||||
| -rw-r--r-- | www/js/MonitorCtrl.js | 16 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 12 | ||||
| -rw-r--r-- | www/js/app.js | 15 | ||||
| -rw-r--r-- | www/js/controllers.js | 5 |
10 files changed, 84 insertions, 142 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index a4f471ef..41e166c9 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -1,3 +1,7 @@ +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ + // This is my central data respository and common functions // that many other controllers use // It's grown over time. I guess I may have to split this into multiple services in the future @@ -300,7 +304,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion var myurl = (monitorId == 0) ? apiurl + "/events.json" : apiurl + "/events/index/MonitorId:" + monitorId + ".json"; if (pageId) { - var myurl = myurl + "?page=" + pageId; + myurl = myurl + "?page=" + pageId; } else { console.log("**** PAGE WAS " + pageId); } @@ -346,7 +350,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion oldevents = []; } return d.promise; - }) + }); return d.promise; } // not simulated }, diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 8b179016..a3955a76 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -1,15 +1,19 @@ +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ + // This is the controller for Event view. StateParams is if I recall the monitor ID. // This was before I got access to the new APIs. FIXME: Revisit this code to see what I am doing with it // and whether the new API has a better mechanism -angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ionicPlatform, $scope, $stateParams, message, ZMDataModel, $ionicSideMenuDelegate, $ionicModal, $ionicLoading, $http, $state, $window) { +angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatform', '$scope', '$stateParams', 'message', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicModal', '$ionicLoading', '$http', '$state', '$window', function ($ionicPlatform, $scope, $stateParams, message, ZMDataModel, $ionicSideMenuDelegate, $ionicModal, $ionicLoading, $http, $state, $window) { console.log("I got STATE PARAM " + $stateParams.id); $scope.id = parseInt($stateParams.id, 10); $scope.connKey = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); - } + }; $scope.reloadView = function () { // All we really need to do here is change the random token @@ -25,7 +29,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion duration: 3000 }); - } + }; $scope.$on('$ionicView.loaded', function () { console.log("**VIEW ** Events Ctrl Loaded"); @@ -42,7 +46,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion $scope.$on('$ionicView.unloaded', function () { console.log("**VIEW ** Events Ctrl Unloaded"); console.log("*** MODAL ** Destroying modal too"); - if (!($scope.modal===undefined)) {$scope.modal.remove()}; + if ($scope.modal!==undefined) {$scope.modal.remove();} }); @@ -57,7 +61,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion stop: "3", pause: "1", play: "2" - } + }; var eventsPage = 1; var moreEvents = true; @@ -71,7 +75,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion $scope.finishedLoadingImage = function () { console.log("*** Events image FINISHED loading ***"); $ionicLoading.hide(); - } + }; $scope.eventCommands = eventCommands; @@ -122,7 +126,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion case "1": toast_blurb = "pausing playback for "; break; - }; + } console.log("** POST URL " + loginData.url + 'zm/index.php'); // You need to POST commands to control zms @@ -175,7 +179,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion req.error(function (resp) { console.log("ERROR: " + JSON.stringify(resp)); }); - } + }; // This is called when we first tap on an event to see // the feed. It's important to instantiate ionicModal here @@ -202,24 +206,25 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion template: "please wait...", noBackdrop: true, duration: 10000 - }) + }); + $scope.modal.show(); - }) - } + }); + }; // We need to destroy because we are instantiating // it on open $scope.closeModal = function () { console.log("Close & Destroy Modal"); - if (!($scope.modal===undefined)) {$scope.modal.remove()}; + if ($scope.modal!==undefined) {$scope.modal.remove();} }; //Cleanup the modal when we're done with it // I Don't think it ever comes here $scope.$on('$destroy', function () { console.log("Destroy Modal"); - if (!($scope.modal===undefined)) {$scope.modal.remove()}; + if ($scope.modal!==undefined) {$scope.modal.remove();} }); console.log("***CALLING EVENTS FACTORY"); @@ -248,7 +253,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion $scope.moreDataCanBeLoaded = function () { return moreEvents; - } + }; $scope.loadMore = function () { console.log("***** LOADING MORE INFINITE SCROLL ****"); @@ -271,7 +276,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion }); - } + }; $scope.isSimulated = function () { return ZMDataModel.isSimulated(); @@ -298,4 +303,4 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ion }); }; //dorefresh -}); +}]); diff --git a/www/js/EventsGraphsCtrl.js b/www/js/EventsGraphsCtrl.js index 5793ed10..94452bc1 100644 --- a/www/js/EventsGraphsCtrl.js +++ b/www/js/EventsGraphsCtrl.js @@ -1,3 +1,8 @@ +/* jshint -W041 */ +/* jshint -W083 */ /*This is for the loop closure I am using in line 143 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console,moment */ + // This controller generates a graph for events // the main function is generateChart. I call generate chart with required parameters // from the template file @@ -5,11 +10,11 @@ // FIXME: I need to clean this up, the animation is stupid because the data loads // dynamically -angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', function ($ionicPlatform, $scope, ZMDataModel, $ionicSideMenuDelegate, $rootScope, $http) { +angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', ['$ionicPlatform', '$scope', 'ZMDataModel', '$ionicSideMenuDelegate', '$rootScope', '$http', function ($ionicPlatform, $scope, ZMDataModel, $ionicSideMenuDelegate, $rootScope, $http) { console.log("Inside Graphs controller"); $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); - } + }; $scope.$on('$ionicView.loaded', function () { console.log("**VIEW ** Graph Ctrl Loaded"); @@ -79,7 +84,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio }, - } + }; var monitors = []; var loginData = ZMDataModel.getLogin(); @@ -143,4 +148,4 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio }; // scope function -}); +}]); diff --git a/www/js/HelpCtrl.js b/www/js/HelpCtrl.js index 37c98d39..35acd30d 100644 --- a/www/js/HelpCtrl.js +++ b/www/js/HelpCtrl.js @@ -1,7 +1,11 @@ -angular.module('zmApp.controllers').controller('zmApp.HelpCtrl', function ($scope, $rootScope, $ionicModal, ZMDataModel,$ionicSideMenuDelegate) { +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ + +angular.module('zmApp.controllers').controller('zmApp.HelpCtrl', ['$scope', '$rootScope', '$ionicModal', 'ZMDataModel','$ionicSideMenuDelegate',function ($scope, $rootScope, $ionicModal, ZMDataModel,$ionicSideMenuDelegate) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); - } + }; console.log ("***** HELP ****"); -}) +}]); diff --git a/www/js/HttpFactory.js b/www/js/HttpFactory.js deleted file mode 100644 index b869e809..00000000 --- a/www/js/HttpFactory.js +++ /dev/null @@ -1,96 +0,0 @@ -// NOT USED ANYMORE. FIXME: DELETE THIS FILE - -angular.module('zmApp.controllers').factory('ZMHttpFactory', ['$http', '$rootScope','$ionicLoading', '$ionicPopup','$timeout' - function($http, $rootScope, $ionicLoading, $ionicPopup, $timeout) { - - - - return { - getMonitors: function(loginData) { - console.log ("Inside HTTP getMonitors"); - $ionicLoading.show({ - template: 'Loading ZoneMinder Monitors...', - animation: 'fade-in', - showBackdrop: true, - maxWidth: 200, - showDelay: 0 - }); - - var monitors = []; - - var apiurl = loginData.apiurl; - var myurl = apiurl+"/monitors.jsona"; - - return $http({ - url: myurl, - method: 'get' - - }) //http - .then(function(response) { - var data = response.data; - //console.log("****YAY" + JSON.stringify(data)); - // $rootScope.$broadcast ('handleZoneMinderMonitorsUpdate',monitors); - $ionicLoading.hide(); - console.log ("** Settings Monitors from HTTP"); - //ZMDataModel.setMonitors(data.monitors); - - // ZMDataModel.setMonitorsLoaded(1); - monitors = data.monitors; - console.log ("**** returning "+monitors.length+" monitors from HTTP"); - return monitors; - }, - function (result) - { - console.log ("**** Error in HTTP"); - $ionicLoading.hide(); - //ZMDataModel.setMonitorsLoaded(1); - //$ionicPopup.alert ({title: "Error", template:"Error retrieving Monitors. \nPlease check if your Settings are correct. "}); - //return ZMDataModel.getMonitors(); - return monitors; - } - ); //then - }, //getMonitors - - getEvents: function(loginData) { - - $ionicLoading.show({ - template: 'Loading ZoneMinder Events...', - animation: 'fade-in', - showBackdrop: true, - maxWidth: 200, - showDelay: 0 - }); - - var myevents = []; - var apiurl = loginData.apiurl; - //var myurl = $rootScope.loginData.url+'/zm/index.php?skin=xml'; - var myurl = apiurl + "/events.json"; - console.log("***MAKING REQUEST to "+ myurl); - return $http({ - url: myurl, - method: 'get', - headers: { - //'Content-Type': 'application/x-www-form-urlencoded', - 'Accept': '*/*', - } - - }) //http - .then(function(response) { - var data = response.data; - // $rootScope.$broadcast ('handleZoneMinderMonitorsUpdate',monitors); - $ionicLoading.hide(); - myevents = response.data; - return myevents.events.reverse(); - }, - function (result) - { - console.log ("**** Error in HTTP"); - $ionicLoading.hide(); - //$ionicPopup.alert ({title: "Error", template:"Error retrieving Monitors. \nPlease check if your Settings are correct. "}); - return myevents; - } - ); //then - }, //getEvents - } - } -]); diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index ef28f2fa..7a4c7695 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -1,7 +1,11 @@ -angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', function ($scope, $rootScope, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading) { +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ + +angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$rootScope', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', function ($scope, $rootScope, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); - } + }; $scope.loginData = ZMDataModel.getLogin(); @@ -100,11 +104,11 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', function ($sco { $ionicPopup.alert({ title: 'Error Details', - template: JSON.stringify(error)}) + template: JSON.stringify(error)}); } } ] - }) + }); } @@ -113,4 +117,4 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', function ($sco }; -}) +}]); diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js index 80758cdd..aec49697 100644 --- a/www/js/MonitorCtrl.js +++ b/www/js/MonitorCtrl.js @@ -1,14 +1,18 @@ +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ + // controller for Monitor View // refer to comments in EventCtrl for the modal stuff. They are almost the same -angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', function ($scope, ZMDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $ionicLoading) { +angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$scope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state',function ($scope, ZMDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state) { $scope.monitors = []; $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); - } + }; $scope.reloadView = function () { console.log("*** Refreshing Modal view ***"); @@ -18,7 +22,7 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', function ($s noBackdrop: true, duration: 2000 }); - } + }; $scope.isSimulated = function () { return ZMDataModel.isSimulated(); @@ -32,7 +36,7 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', function ($s template: "loading, please wait...", noBackdrop: true, });*/ - } + }; @@ -71,7 +75,7 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', function ($s template: "please wait...", noBackdrop: true, duration: 15000 - }) + }); $scope.modal.show(); }); @@ -105,4 +109,4 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', function ($s }; -}); +}]); diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index c85011b0..3500dbfa 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -1,6 +1,10 @@ // Controller for the montage view +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ -angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', function ($scope, $rootScope, ZMDataModel, message,$ionicSideMenuDelegate, $timeout, $interval) { + +angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '$rootScope', 'ZMDataModel', 'message','$ionicSideMenuDelegate', '$timeout', '$interval', function ($scope, $rootScope, ZMDataModel, message,$ionicSideMenuDelegate, $timeout, $interval) { var timestamp = new Date().getUTCMilliseconds(); @@ -42,7 +46,7 @@ function onPause() { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); - } + }; $scope.$on('$destroy', function () { console.log ("*** CANCELLING INTERVAL ****"); @@ -70,7 +74,7 @@ function onPause() { $scope.isSimulated = function () { return ZMDataModel.isSimulated(); - } + }; @@ -117,4 +121,4 @@ function onPause() { }); }; -}); +}]); diff --git a/www/js/app.js b/www/js/app.js index d303a894..e1c724b5 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1,7 +1,12 @@ +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ + + // core app start stuff angular.module('zmApp', [ 'ionic', - 'zmApp.controllers', + 'zmApp.controllers' ]) @@ -20,7 +25,7 @@ angular.module('zmApp', [ //call the function that was passed scope.$apply(attrs.imageonload); }); - }, + } }; @@ -100,8 +105,8 @@ angular.module('zmApp', [ setTimeout(function () { - $cordovaSplashscreen.hide() - }, 1500) + $cordovaSplashscreen.hide(); + }, 1500); var pixelRatio = window.devicePixelRatio || 1; $rootScope.devWidth = ((window.innerWidth > 0) ? window.innerWidth : screen.width); @@ -151,7 +156,7 @@ angular.module('zmApp', [ controller: 'zmApp.LoginCtrl', - }) + }); $stateProvider .state('help', { diff --git a/www/js/controllers.js b/www/js/controllers.js index bb0e3208..70c0cc39 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -1,3 +1,6 @@ +/* jshint -W041 */ +/* jshint browser: true*/ +/* global cordova,StatusBar,angular,console */ angular.module('zmApp.controllers', ['ionic', 'googlechart', 'ngCordova', 'ng-mfb' ]) @@ -5,5 +8,5 @@ angular.module('zmApp.controllers', ['ionic', 'googlechart', 'ngCordova', 'ng- .controller('zmApp.AppCtrl', function($scope, $ionicSideMenuDelegate) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); - } + }; }); |
