summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArjun Roychowdhury <pliablepixels@gmail.com>2015-11-11 11:26:34 -0500
committerArjun Roychowdhury <pliablepixels@gmail.com>2015-11-11 11:26:34 -0500
commit1ab390f225b727303df305fefa72bb3ac4b069b8 (patch)
tree5cdde2836527098ec0e4b8539b0769dff1c7128c
parentf087b5f125f5545252e2f426582f910d0b88e241 (diff)
#81 - initial commits to start using localstorage
Former-commit-id: 18a55518ba7f11881a677092b5f1c1a35be1b443
-rw-r--r--www/index.html2
-rw-r--r--www/js/DataModel.js8
-rw-r--r--www/js/app.js34
-rw-r--r--www/js/controllers.js2
-rw-r--r--www/js/ionicUtils.js22
5 files changed, 44 insertions, 24 deletions
diff --git a/www/index.html b/www/index.html
index 958bf490..f05510d6 100644
--- a/www/index.html
+++ b/www/index.html
@@ -44,6 +44,7 @@
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
+ <script src="js/ionicUtils.js"></script>
@@ -83,6 +84,7 @@
<script src="js/EventServerSettingsCtrl.js"></script>
<script src="js/FirstUseCtrl.js"></script>
+
<script src="external/ng-websocket.js"></script>
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index caca93d6..2c1fe144 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -11,11 +11,11 @@
angular.module('zmApp.controllers')
.service('ZMDataModel',
-['$http', '$q', '$ionicLoading', '$ionicBackdrop', '$fileLogger', 'zm','$rootScope','$ionicContentBanner', '$timeout','$cordovaPinDialog', '$ionicPopup',
+['$http', '$q', '$ionicLoading', '$ionicBackdrop', '$fileLogger', 'zm','$rootScope','$ionicContentBanner', '$timeout','$cordovaPinDialog', '$ionicPopup', '$localstorage',
function
($http, $q, $ionicLoading, $ionicBackdrop,$fileLogger,
zm, $rootScope,$ionicContentBanner, $timeout, $cordovaPinDialog,
- $ionicPopup) {
+ $ionicPopup, $localstorage) {
var zmAppVersion="unknown";
var isBackground = false;
@@ -452,6 +452,10 @@ angular.module('zmApp.controllers')
zmLog("Saving all parameters to storage");
zmDebug ("DataModel/setLogin: writing " + JSON.stringify(newLogin));
+ $localstorage.setObject('myserver', newLogin);
+
+
+
window.localStorage.setItem("username", loginData.username);
window.localStorage.setItem("password", loginData.password);
window.localStorage.setItem("url", loginData.url);
diff --git a/www/js/app.js b/www/js/app.js
index 47bda7e5..94551555 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -107,7 +107,7 @@ angular.module('zmApp', [
})
//------------------------------------------------------------------
-// this directive will be load any time an image completes loading
+// this directive will be called any time an image completes loading
// via img tags where this directive is added (I am using this in
// events and monitor view to show a loader while the image is
// downloading from ZM
@@ -191,10 +191,10 @@ angular.module('zmApp', [
$element[0].style.backgroundImage = 'url(' + $attributes.imageSpinnerSrc + ')';
};
bgImg.src = $attributes.imageSpinnerSrc;
- //console.log ("DIRECTIVE: BGIMAGE SRC SET TO " + $attributes.imageSpinnerSrc);
+
} else {
$element[0].src = $attributes.imageSpinnerSrc; // set src attribute on element (it will load image)
- //console.log ("DIRECTIVE: IMAGE SRC SET TO "+$attributes.imageSpinnerSrc);
+
}
}
@@ -203,9 +203,9 @@ angular.module('zmApp', [
}
$element.on('$destroy', function () {
- // console.log ("**************** DIRECTIVE DESTROY IMAGE: " + $element[0].src);
+
});
- // $element[0].src = "img/novideo.png";
+
}
};
@@ -213,8 +213,6 @@ angular.module('zmApp', [
-
-
//------------------------------------------------------------------
// In Android, HTTP requests seem to get stuck once in a while
// It may be a crosswalk issue.
@@ -282,9 +280,7 @@ angular.module('zmApp', [
zmCookie = zmSess[1];
}
- } else {
- // console.log ("WHOLE STRING " + cookies);
- }
+ }
}
return response;
}
@@ -525,9 +521,10 @@ angular.module('zmApp', [
})
-//------------------------------------------------------------------
+//====================================================================
// First run in ionic
-//------------------------------------------------------------------
+//====================================================================
+
.run(function ($ionicPlatform, $ionicPopup, $rootScope, zm, $state, $stateParams, ZMDataModel, $cordovaSplashscreen, $http, $interval, zmAutoLogin, $fileLogger, $timeout, $ionicHistory, $window, $ionicSideMenuDelegate, EventServer,$ionicContentBanner) {
@@ -549,7 +546,7 @@ angular.module('zmApp', [
$rootScope.platformOS="desktop";
-
+ // This is a global exception interceptor
$rootScope.exceptionMessage = function(error)
{
ZMDataModel.zmDebug("**EXCEPTION**"+error.reason+" caused by " + error.cause);
@@ -615,7 +612,7 @@ angular.module('zmApp', [
event.preventDefault();
$state.transitionTo('login');
}
- console.log ("IN RETURN");
+
return;
});
@@ -787,10 +784,6 @@ angular.module('zmApp', [
}); //platformReady
-
-
-
-
}) //run
//------------------------------------------------------------------
@@ -1027,10 +1020,9 @@ angular.module('zmApp', [
$urlRouterProvider.otherwise(function ($injector, $location) {
var $state = $injector.get("$state");
- //console.log ("******************* OTHERWISE PROBLEM");
- // var $rootScope = $injector.get('$rootScope');
+
$state.go("zm-portal-login");
- //$state.transitionTo('zm-portal-login');
+
});
}); //config \ No newline at end of file
diff --git a/www/js/controllers.js b/www/js/controllers.js
index cbb8fa9e..412f9831 100644
--- a/www/js/controllers.js
+++ b/www/js/controllers.js
@@ -4,7 +4,7 @@
-angular.module('zmApp.controllers', ['ionic', 'ngCordova', 'ng-mfb','angularCircularNavigation', 'jett.ionic.content.banner', 'ionic-pullup', 'ngWebsocket' ])
+angular.module('zmApp.controllers', ['ionic', 'ionic.utils', 'ngCordova', 'ng-mfb','angularCircularNavigation', 'jett.ionic.content.banner', 'ionic-pullup', 'ngWebsocket' ])
.controller('zmApp.BaseController', function($scope, $ionicSideMenuDelegate, $ionicPlatform, $timeout, $rootScope) {
$scope.openMenu = function () {
diff --git a/www/js/ionicUtils.js b/www/js/ionicUtils.js
new file mode 100644
index 00000000..ac79e87e
--- /dev/null
+++ b/www/js/ionicUtils.js
@@ -0,0 +1,22 @@
+/* jshint -W041 */
+/* jshint browser: true*/
+/* global cordova,StatusBar,angular,console */
+
+angular.module('ionic.utils', [])
+
+.factory('$localstorage', ['$window', function($window) {
+ return {
+ set: function(key, value) {
+ $window.localStorage[key] = value;
+ },
+ get: function(key, defaultValue) {
+ return $window.localStorage[key] || defaultValue;
+ },
+ setObject: function(key, value) {
+ $window.localStorage[key] = JSON.stringify(value);
+ },
+ getObject: function(key) {
+ return JSON.parse($window.localStorage[key] || '{}');
+ }
+ };
+}]);