summaryrefslogtreecommitdiff
path: root/www/js/LoginCtrl.js
diff options
context:
space:
mode:
authorPliablePixels <pliablepixels@gmail.com>2015-06-24 18:47:42 -0400
committerPliablePixels <pliablepixels@gmail.com>2015-06-24 18:47:42 -0400
commit855a0e8ddc273b58066530a1b55a946021dfc56e (patch)
tree26550033e855a31a265fc2da4da3df0cc2733dc1 /www/js/LoginCtrl.js
parentd442629aa825aab6bc55ab6be19e3aba060867fe (diff)
Cleaned up code, commented, preparing for HTTPS via CordovaHTTP
Diffstat (limited to 'www/js/LoginCtrl.js')
-rw-r--r--www/js/LoginCtrl.js40
1 files changed, 37 insertions, 3 deletions
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js
index b787f509..e014500b 100644
--- a/www/js/LoginCtrl.js
+++ b/www/js/LoginCtrl.js
@@ -9,10 +9,21 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
$scope.loginData = ZMDataModel.getLogin();
-
-
+//-------------------------------------------------------------------------------
+// Adds http to url if not present
+// http://stackoverflow.com/questions/11300906/check-if-a-string-starts-with-http-using-javascript
+//-------------------------------------------------------------------------------
+function addhttp(url) {
+ if (!/^(f|ht)tps?:\/\//i.test(url)) {
+ url = "http://" + url;
+ }
+ return url;
+}
+
+ //-----------------------------------------------------------------------------
// Perform the login action when the user submits the login form
- $scope.login = function () {
+ //-----------------------------------------------------------------------------
+ $scope.save = function () {
console.log('Saving login');
if (parseInt($scope.loginData.maxMontage) > 10) {
@@ -55,6 +66,29 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
$scope.loginData.streamingurl = $scope.loginData.streamingurl.slice(0, -7);
}
+ // check for protocol and if not put it in
+
+ $scope.loginData.url = addhttp($scope.loginData.url);
+ $scope.loginData.apiurl = addhttp($scope.loginData.apiurl);
+ $scope.loginData.streamingurl = addhttp($scope.loginData.streamingurl);
+
+ if ($scope.loginData.useSSL)
+ {
+ // replace all http with https
+ $scope.loginData.url = $scope.loginData.url.replace("http:","https:");
+ $scope.loginData.apiurl = $scope.loginData.apiurl.replace("http:","https:");
+ $scope.loginData.streamingurl = $scope.loginData.streamingurl.replace("http:","https:");
+
+ }
+ else
+ {
+ // replace all https with http
+ $scope.loginData.url = $scope.loginData.url.replace("https:","http:");
+ $scope.loginData.apiurl = $scope.loginData.apiurl.replace("https:","http:");
+ $scope.loginData.streamingurl = $scope.loginData.streamingurl.replace("https:","http:");
+ }
+
+
// FIXME:: Do a login id check too