diff options
| author | ARC <arjunrc@gmail.com> | 2015-04-28 11:26:57 -0400 |
|---|---|---|
| committer | ARC <arjunrc@gmail.com> | 2015-04-28 11:26:57 -0400 |
| commit | 6fa29c170159e7bfbcaf7681cdfb52ba7f98cac0 (patch) | |
| tree | 0039de6ab6324d0d91cb63383a290a9205541043 /www/js | |
| parent | 6e83957c0231d48eb9f29d1270806cadef3a3c6d (diff) | |
Events navigation not works with a cool full screen mode and floating buttons
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/EventCtrl.js | 176 | ||||
| -rw-r--r-- | www/js/app.js | 3 | ||||
| -rw-r--r-- | www/js/controllers.js | 2 |
3 files changed, 141 insertions, 40 deletions
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 3b29af15..c6eba07e 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -2,43 +2,144 @@ // 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) { +angular.module('zmApp.controllers').controller('zmApp.EventCtrl', function ($ionicPlatform, $scope, $stateParams, message, ZMDataModel, $ionicSideMenuDelegate, $ionicModal, $ionicLoading, $http) { console.log("I got STATE PARAM " + $stateParams.id); - $scope.id = parseInt($stateParams.id,10); - -$scope.openMenu = function () { - $ionicSideMenuDelegate.toggleLeft(); - } - -// This is a modal to show the event footage -$ionicModal.fromTemplateUrl('templates/events-modal.html', { - scope: $scope, - animation: 'slide-in-up' - }) - .then(function(modal) { - $scope.modal = modal; - - }); - - -$scope.openModal = function(eid,ename,edur) { - console.log ("Open Modal"); - $scope.eventName = ename; - $scope.eventId = eid; - $scope.eventDur = Math.round(edur); - $scope.loginData = ZMDataModel.getLogin(); - $scope.modal.show(); - }; - $scope.closeModal = function() { - console.log ("Close Modal"); - $scope.modal.hide(); - - }; - //Cleanup the modal when we're done with it! - $scope.$on('$destroy', function() { - console.log ("Destroy Modal"); - $scope.modal.remove(); - }); + $scope.id = parseInt($stateParams.id, 10); + $scope.connKey = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; + + $scope.openMenu = function () { + $ionicSideMenuDelegate.toggleLeft(); + } + + // This is a modal to show the event footage + $ionicModal.fromTemplateUrl('templates/events-modal.html', { + scope: $scope, + animation: 'slide-in-up' + }) + .then(function (modal) { + $scope.modal = modal; + + }); + + var eventCommands = { + next: "13", + previous: "12", + zoomin: "8", + zoomout: "9", + stop: "3", + pause: "1", + play: "2" + } + + + $scope.eventCommands = eventCommands; + + // this routine handles skipping through events + // in different event views + $scope.controlEventStream = function (cmd) { + console.log("Command value " + cmd); + + if (ZMDataModel.isSimulated()) { + var str = "simulation mode. no action taken"; + $ionicLoading.show({ + template: str, + noBackdrop: true, + duration: 3000 + }); + return; + } + + + var loginData = ZMDataModel.getLogin(); + + var toast_blurb = ""; + switch (cmd) { + case "13": + toast_blurb = "moving to "; + break; + case "12": + toast_blurb = "moving to "; + break; + case "8": + toast_blurb = "zoomed into "; + break; + case "9": + toast_blurb = "zoomed out of "; + break; + case "3": + toast_blurb = "stopping playback for "; + break; + case "2": + toast_blurb = "resuming playback for "; + break; + case "1": + toast_blurb = "pausing playback for "; + break; + }; + + + var req = $http({ + method: 'POST', + url: loginData.url + 'zm/index.php', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': '*/*', + }, + transformRequest: function (obj) { + var str = []; + for (var p in obj) + str.push(encodeURIComponent(p) + "=" + + encodeURIComponent(obj[p])); + var foo = str.join("&"); + console.log("****RETURNING " + foo); + return foo; + }, + + data: { + view: "request", + request: "stream", + connkey: $scope.connKey, + command: cmd, + user: loginData.username, + pass: loginData.password + } + }); + req.success(function (resp) { + + console.log("SUCCESS: " + JSON.stringify(resp)); + var str = toast_blurb + "Event:" + resp.status.event; + console.log(str); + $ionicLoading.show({ + template: str, + noBackdrop: true, + duration: 3000 + }); + }); + + req.error(function (resp) { + console.log("ERROR: " + JSON.stringify(resp)); + }); + } + + + $scope.openModal = function (eid, ename, edur) { + console.log("Open Modal"); + $scope.eventName = ename; + $scope.eventId = eid; + $scope.eventDur = Math.round(edur); + $scope.loginData = ZMDataModel.getLogin(); + $scope.modal.show(); + }; + $scope.closeModal = function () { + console.log("Close Modal"); + $scope.modal.hide(); + + }; + //Cleanup the modal when we're done with it! + $scope.$on('$destroy', function () { + console.log("Destroy Modal"); + $scope.modal.remove(); + }); console.log("***CALLING EVENTS FACTORY"); var lData = ZMDataModel.getLogin(); @@ -58,8 +159,7 @@ $scope.openModal = function(eid,ename,edur) { $scope.events = myevents; }); -$scope.isSimulated = function () - { + $scope.isSimulated = function () { return ZMDataModel.isSimulated(); }; diff --git a/www/js/app.js b/www/js/app.js index b89dcb78..77ab0c38 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -7,9 +7,10 @@ angular.module('zmApp', [ .run(function ($ionicPlatform, $ionicPopup, $rootScope, $state, ZMDataModel,$cordovaSplashscreen) { + // generates and error in desktops but works fine setTimeout(function() { $cordovaSplashscreen.hide() - }, 5000) + }, 3000) ZMDataModel.init(); var loginData = ZMDataModel.getLogin(); diff --git a/www/js/controllers.js b/www/js/controllers.js index b590d436..75875f60 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -1,5 +1,5 @@ -angular.module('zmApp.controllers', ['ionic', 'googlechart', 'ngCordova' ]) +angular.module('zmApp.controllers', ['ionic', 'googlechart', 'ngCordova', 'ng-mfb' ]) .controller('zmApp.AppCtrl', function($scope, $ionicSideMenuDelegate) { $scope.openMenu = function () { |
