summaryrefslogtreecommitdiff
path: root/www/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/app.js')
-rw-r--r--www/js/app.js72
1 files changed, 45 insertions, 27 deletions
diff --git a/www/js/app.js b/www/js/app.js
index 367fc0af..eb254aa8 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -1,7 +1,13 @@
/* jshint -W041 */
/* jslint browser: true*/
-/* global cordova,StatusBar,angular,console,alert,PushNotification, moment ,ionic, URI,Packery, ConnectSDK, CryptoJS, localforage,$*/
+/* global cordova,StatusBar,angular,console,alert,PushNotification, moment ,ionic, URI,Packery, ConnectSDK, CryptoJS, ContactFindOptions, localforage,$, Connection*/
+// For desktop versions, this is replaced
+// with actual app version from config.xml by the
+// ./make_desktop.sh script
+
+// For mobile versions, I use cordova app version plugin
+// to get it at run time
var appVersion = "0.0.0";
@@ -46,7 +52,7 @@ angular.module('zmApp', [
authoremail: 'pliablepixels+zmNinja@gmail.com',
logFileMaxSize: 20000, // after this limit log gets reset
loginInterval: 300000, //5m*60s*1000 - ZM auto login after 5 mins
- loginIntervalLowBW: 600000, //10m login
+
//loginInterval: 30000,
updateCheckInterval: 86400000, // 24 hrs
loadingTimeout: 15000,
@@ -78,11 +84,18 @@ angular.module('zmApp', [
nphSwitchTimer: 3000,
eventHistoryTimer: 10000,
eventPlaybackQuery: 3000,
- eventPlaybackQueryLowBW: 6000,
+
packeryTimer: 500,
dbName: 'zmninja',
cipherKey: 'sdf#@#%FSXSA_AR',
minCycleTime: 5,
+
+ eventPlaybackQueryLowBW: 6000,
+ loginIntervalLowBW: 600000, //10m login
+ eventSingleImageQualityLowBW:70,
+ monSingleImageQualityLowBW:70,
+ montageQualityLowBW:50,
+ eventMontageQualityLowBW:50
})
@@ -109,18 +122,6 @@ angular.module('zmApp', [
})
-// https://forum.ionicframework.com/t/ng-src-not-updated-in-video-tag/7540/6
-.directive('dynamicUrl', function () {
- return {
- restrict: 'A',
- link: function postLink(scope, element, attr) {
- element.attr('src', attr.dynamicUrlSrc);
- }
- };
-})
-
-
-
// credit https://gist.github.com/Zren/beaafd64f395e23f4604
@@ -577,8 +578,8 @@ angular.module('zmApp', [
$rootScope.newBlogPost = "(new post)";
return;
+
}
-
var mLastDate = moment(lastDate);
var mItemDate = moment(data[0].date);
@@ -968,11 +969,35 @@ angular.module('zmApp', [
$rootScope.$apply(function () {
$rootScope.online = false;
NVRDataModel.log("Your network went offline");
+
+ //$rootScope.$emit('network-change', "offline");
+
});
}, false);
+
$window.addEventListener("online", function () {
$rootScope.$apply(function () {
$rootScope.online = true;
+
+ $timeout ( function () {
+ var networkState = navigator.connection.type;
+ NVRDataModel.debug ("Detected network type as: "+ networkState);
+ var strState = NVRDataModel.getBandwidth();
+ NVRDataModel.debug ("getBandwidth() normalized it as: " + strState);
+ $rootScope.runMode = strState;
+ if ((NVRDataModel.getLogin().autoSwitchBandwidth == true) &&
+ (NVRDataModel.getLogin().enableLowBandwidth == true))
+ {
+ NVRDataModel.debug ("Setting app state to: "+ strState);
+ $rootScope.$emit('bandwidth-change', strState);
+ }
+ else
+ {
+ NVRDataModel.debug ("Not changing bandwidth state, as auto change is not on");
+ }
+
+ },1000); // need a time gap, seems network type registers late
+
NVRDataModel.log("Your network is online, re-authenticating");
zmAutoLogin.doLogin($translate.instant('kReAuthenticating'));
@@ -1077,11 +1102,8 @@ angular.module('zmApp', [
-
-
-
$rootScope.db = null;
- $rootScope.runMode = "normal";
+ $rootScope.runMode = NVRDataModel.getBandwidth();
$rootScope.platformOS = "desktop";
NVRDataModel.log("Device is ready");
@@ -1424,12 +1446,6 @@ angular.module('zmApp', [
}
-
-
-
-
-
-
}); //platformReady
}) //run
@@ -1485,7 +1501,7 @@ angular.module('zmApp', [
//$translateProvider.useLocalStorage();
- $translateProvider.registerAvailableLanguageKeys(['en', 'de', 'es', 'fr', 'it', 'ja', 'ko', 'zh', 'zh_CN', 'zh_TW', 'pt'], {
+ $translateProvider.registerAvailableLanguageKeys(['en', 'de', 'es', 'fr', 'it', 'ja', 'ko', 'zh', 'zh_CN', 'zh_TW', 'pt', 'ar','hi'], {
'en_*': 'en',
'de_*': 'de',
'es_*': 'es',
@@ -1494,6 +1510,8 @@ angular.module('zmApp', [
'ja_*': 'ja',
'ko_*': 'ko',
'pt_*': 'pt',
+ 'ar_*': 'ar',
+ 'hi_*': 'hi',
'*': 'en' // must be last
});