From 5c6bd778aee817b81e09e71ca55494c8d0aa4f1f Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 9 Sep 2016 19:28:46 -0400 Subject: #321 initial bw fix Former-commit-id: fe6361043c82ae7204ed4ce5741aa5af1290ecb5 --- www/js/DataModel.js | 62 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'www/js/DataModel.js') diff --git a/www/js/DataModel.js b/www/js/DataModel.js index c5649b93..435b9bf9 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -145,6 +145,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 //-------------------------------------------------------------------------- @@ -712,6 +743,9 @@ angular.module('zmApp.controllers') } + $rootScope.runMode = getBandwidth(); + log("Setting DataModel init bandwidth to: " +$rootScope.runMode); + @@ -1100,33 +1134,7 @@ angular.module('zmApp.controllers') // returns high or low BW mode //-------------------------------------------------------------------------- getBandwidth: function () { - // 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; + return getBandwidth(); }, //-------------------------------------------------------------------------- -- cgit v1.2.3