summaryrefslogtreecommitdiff
path: root/www/js/DataModel.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/DataModel.js')
-rw-r--r--www/js/DataModel.js78
1 files changed, 75 insertions, 3 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 11451916..dcd6b768 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -2,7 +2,7 @@
/* jslint browser: true*/
-/* global cordova,StatusBar,angular,console, URI, moment, localforage, CryptoJS */
+/* global cordova,StatusBar,angular,console, URI, moment, localforage, CryptoJS, Connection */
// This is my central data respository and common functions
// that many other controllers use
@@ -39,7 +39,15 @@ angular.module('zmApp.controllers')
{
text: 'Portugese',
value: 'pt'
- }
+ },
+ /*{
+ text: 'Arabic',
+ value: 'ar'
+ },
+ {
+ text: 'Hindi',
+ value: 'hi'
+ }*/
];
var serverGroupList = {};
@@ -109,6 +117,8 @@ angular.module('zmApp.controllers')
'cycleMonitors': false,
'cycleMonitorsInterval':10, // 10sec
'enableLowBandwidth':false,
+ 'autoSwitchBandwidth':false,
+ 'disableAlarmCheckMontage': false,
@@ -144,6 +154,37 @@ angular.module('zmApp.controllers')
return true;
}
+ function getBandwidth()
+ {
+ // if mode is not on always return high
+ if (loginData.enableLowBandwidth == false)
+ {
+ return "highbw";
+ }
+ // if mode is force on, return low
+ if (loginData.enableLowBandwidth == true && loginData.autoSwitchBandwidth != true)
+ {
+ return "lowbw";
+ }
+ if (loginData.enableLowBandwidth == true && loginData.autoSwitchBandwidth == true && $rootScope.platformOS == 'desktop')
+ {
+ return "highbw";
+ }
+ // else return real state
+
+ var networkState = navigator.connection.type;
+ var strState;
+ switch (networkState)
+ {
+
+ case Connection.WIFI: strState="highbw"; break;
+ case Connection.ETHERNET: strState="highbw"; break;
+ default: strState = "lowbw"; break;
+
+ }
+ return strState;
+ }
+
//--------------------------------------------------------------------------
// uses fileLogger to write logs to file for later investigation
//--------------------------------------------------------------------------
@@ -691,12 +732,31 @@ angular.module('zmApp.controllers')
}
+
if (typeof loginData.enableLowBandwidth == 'undefined') {
+
loginData.enableLowBandwidth = false;
}
- $rootScope.runMode = loginData.enableLowBandwith? "low": "normal";
+ // wtf is wrong with this ternary?
+ //$rootScope.runMode = (loginData.enableLowBandwith==true)? "low": "normal";
+
+
+
+
+ if (typeof loginData.autoSwitchBandwidth == 'undefined') {
+
+
+ loginData.autoSwitchBandwidth = false;
+
+ }
+
+ $rootScope.runMode = getBandwidth();
+ log("Setting DataModel init bandwidth to: " +$rootScope.runMode);
+
+
+
if (typeof loginData.refreshSecLowBW == 'undefined') {
@@ -704,6 +764,12 @@ angular.module('zmApp.controllers')
}
+ if (typeof loginData.disableAlarmCheckMontage == 'undefined') {
+
+ loginData.disableAlarmCheckMontage = false;
+
+ }
+
@@ -1079,6 +1145,12 @@ angular.module('zmApp.controllers')
},
+ //--------------------------------------------------------------------------
+ // returns high or low BW mode
+ //--------------------------------------------------------------------------
+ getBandwidth: function () {
+ return getBandwidth();
+ },
//--------------------------------------------------------------------------
// This is really a hack for now & is very ugly. I need to clean this up a lot