0
0
mirror of https://github.com/Doodle3D/doodle3d-connect.git synced 2024-12-26 02:23:48 +01:00

Clear all running processes on page hides

This commit is contained in:
peteruithoven 2014-05-12 14:43:59 +02:00
parent deb9cab48b
commit 34a28911f8
2 changed files with 17 additions and 7 deletions

View File

@ -52,6 +52,10 @@ var BoxPage = (function (w) {
_networkAPI.init(boxURL); _networkAPI.init(boxURL);
retrieveNetworkStatus(); retrieveNetworkStatus();
}); });
$.mobile.document.on( "pagehide", PAGE_ID, function( event, data ) {
clearTimeout(_retryRetrieveStatusDelay);
});
function retrieveNetworkStatus() { function retrieveNetworkStatus() {
//console.log("retrieveNetworkStatus"); //console.log("retrieveNetworkStatus");

View File

@ -13,6 +13,7 @@
var _actionField; var _actionField;
var _networkAPI = new NetworkAPI(); var _networkAPI = new NetworkAPI();
var _connectAPI = new ConnectAPI(); var _connectAPI = new ConnectAPI();
var _connectedBoxNetworkAPI = new NetworkAPI();
var _infoAPI = new InfoAPI(); var _infoAPI = new InfoAPI();
var _pageData = {}; var _pageData = {};
var _formData; var _formData;
@ -21,7 +22,9 @@
var _connectedChecking = false; var _connectedChecking = false;
var CONNECTED_REDIRECT_DELAY = 5000; var CONNECTED_REDIRECT_DELAY = 5000;
var _connectedRedirectDelay;
var BACKUP_REDIRECT_DELAY = 10*1000; // when the wifiboxid isn't retrievable we want to redirect anyway var BACKUP_REDIRECT_DELAY = 10*1000; // when the wifiboxid isn't retrievable we want to redirect anyway
var _backupRedirectDelay;
var PAGE_ID = "#connecting_to_network"; var PAGE_ID = "#connecting_to_network";
var _self = this; var _self = this;
@ -53,6 +56,9 @@
console.log("Connecting to network page pagehide"); console.log("Connecting to network page pagehide");
_networkAPI.stopAutoRefresh(); _networkAPI.stopAutoRefresh();
_connectAPI.stop(); _connectAPI.stop();
_connectedBoxNetworkAPI.stopAutoRefresh();
clearTimeout(_connectedRedirectDelay);
clearTimeout(_backupRedirectDelay);
}); });
function retrieveWiFiBoxID(completeHandler) { function retrieveWiFiBoxID(completeHandler) {
console.log(PAGE_ID+":retrieveWiFiBoxID"); console.log(PAGE_ID+":retrieveWiFiBoxID");
@ -148,9 +154,9 @@
function checkBox(boxData) { function checkBox(boxData) {
// check if it finished connecting // check if it finished connecting
var boxURL = "http://"+boxData.localip; var boxURL = "http://"+boxData.localip;
var connectedBoxNetworkAPI = new NetworkAPI(); _connectedBoxNetworkAPI = new NetworkAPI();
connectedBoxNetworkAPI.init(boxURL); _connectedBoxNetworkAPI.init(boxURL);
connectedBoxNetworkAPI.updated = function(data) { _connectedBoxNetworkAPI.updated = function(data) {
data.status = parseInt(data.status,10); data.status = parseInt(data.status,10);
console.log(PAGE_ID+":connectedBoxNetworkAPI:onStatusUpdated: ",data.status); console.log(PAGE_ID+":connectedBoxNetworkAPI:onStatusUpdated: ",data.status);
// if box finished connecting // if box finished connecting
@ -162,14 +168,14 @@
// prevent status changes by wired box // prevent status changes by wired box
_networkAPI.stopAutoRefresh(); _networkAPI.stopAutoRefresh();
setTimeout(function () { _connectedRedirectDelay = setTimeout(function () {
// redirect to it's box page // redirect to it's box page
console.log(" redirect to box"); console.log(" redirect to box");
var linkParams = {localip: boxData.localip,wifiboxid: boxData.wifiboxid}; var linkParams = {localip: boxData.localip,wifiboxid: boxData.wifiboxid};
var link = "#box"; var link = "#box";
link = d3d.util.replaceURLParameters(link,linkParams); link = d3d.util.replaceURLParameters(link,linkParams);
$.mobile.changePage(link); $.mobile.changePage(link);
connectedBoxNetworkAPI.stopAutoRefresh(); _connectedBoxNetworkAPI.stopAutoRefresh();
// disable warnings that are enabled on boxes page // disable warnings that are enabled on boxes page
d3d.util.disableRefreshPrevention(); d3d.util.disableRefreshPrevention();
@ -177,10 +183,10 @@
},CONNECTED_REDIRECT_DELAY); },CONNECTED_REDIRECT_DELAY);
} }
}; };
connectedBoxNetworkAPI.startAutoRefresh(); _connectedBoxNetworkAPI.startAutoRefresh();
} }
function onListSuccess() { function onListSuccess() {
setTimeout(function () { _backupRedirectDelay = setTimeout(function () {
$.mobile.changePage("#boxes"); $.mobile.changePage("#boxes");
},BACKUP_REDIRECT_DELAY); },BACKUP_REDIRECT_DELAY);
} }