mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-28 11:34:56 +01:00
Moved retries out of API classes
This commit is contained in:
parent
eaed4c9efc
commit
16078d3478
@ -12,7 +12,6 @@ function ConfigAPI() {
|
||||
var _wifiboxCGIBinURL;
|
||||
var _timeoutTime = 3000;
|
||||
var _saveSettingsTimeoutTime = 8000;
|
||||
var _retryDelay = 2000; // retry setTimout delay
|
||||
|
||||
var _self = this;
|
||||
|
||||
@ -31,13 +30,13 @@ function ConfigAPI() {
|
||||
timeout: _timeoutTime,
|
||||
success: function(response){
|
||||
if(response.status == "error" || response.status == "fail") {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler(response);
|
||||
} else {
|
||||
completeHandler(response.data);
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler();
|
||||
});
|
||||
};
|
||||
this.load = function(targetSettings,completeHandler,failedHandler) {
|
||||
@ -50,13 +49,13 @@ function ConfigAPI() {
|
||||
timeout: _timeoutTime,
|
||||
success: function(response){
|
||||
if(response.status == "error" || response.status == "fail") {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler(response);
|
||||
} else {
|
||||
completeHandler(response.data);
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler();
|
||||
});
|
||||
};
|
||||
this.save = function(newSettings,completeHandler,failedHandler) {
|
||||
@ -70,13 +69,13 @@ function ConfigAPI() {
|
||||
success: function(response){
|
||||
//console.log("ConfigAPI:save response: ",response);
|
||||
if(response.status == "error" || response.status == "fail") {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler(response);
|
||||
} else {
|
||||
completeHandler(response.data);
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler();
|
||||
});
|
||||
};
|
||||
this.resetAll = function(completeHandler,failedHandler) {
|
||||
@ -88,13 +87,13 @@ function ConfigAPI() {
|
||||
timeout: _timeoutTime,
|
||||
success: function(response){
|
||||
if(response.status == "error" || response.status == "fail") {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler(response);
|
||||
} else {
|
||||
completeHandler(response.data);
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler();
|
||||
});
|
||||
};
|
||||
}
|
@ -19,7 +19,6 @@ function NetworkAPI() {
|
||||
var _wifiboxURL;
|
||||
var _wifiboxCGIBinURL;
|
||||
var _timeoutTime = 3000;
|
||||
var _retryDelay = 2000; // retry setTimout delay
|
||||
|
||||
var _self = this;
|
||||
|
||||
@ -31,6 +30,7 @@ function NetworkAPI() {
|
||||
_wifiboxCGIBinURL = wifiboxCGIBinURL;
|
||||
}
|
||||
this.scan = function(completeHandler) {
|
||||
this.scan = function(completeHandler,failedHandler) {
|
||||
//console.log("NetworkAPI:scan");
|
||||
//console.log(" _wifiboxURL: ",_wifiboxURL);
|
||||
$.ajax({
|
||||
@ -41,13 +41,15 @@ function NetworkAPI() {
|
||||
success: function(response){
|
||||
//console.log("NetworkAPI:scan response: ",response);
|
||||
if(response.status == "error" || response.status == "fail") {
|
||||
console.log("NetworkAPI:scan failed: ",response);
|
||||
//console.log("NetworkAPI:scan failed: ",response);
|
||||
if(failedHandler) failedHandler(response);
|
||||
} else {
|
||||
completeHandler(response.data);
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
console.log("NetworkAPI:scan failed");
|
||||
//console.log("NetworkAPI:scan failed");
|
||||
if(failedHandler) failedHandler();
|
||||
});
|
||||
};
|
||||
this.status = function(completeHandler,failedHandler) {
|
||||
@ -60,13 +62,13 @@ function NetworkAPI() {
|
||||
success: function(response){
|
||||
//console.log("NetworkAPI:status response: ",response);
|
||||
if(response.status == "error" || response.status == "fail") {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler(response);
|
||||
} else {
|
||||
completeHandler(response.data);
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
failedHandler();
|
||||
if(failedHandler) failedHandler();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,10 @@ function FormPanel() {
|
||||
var _configAPI = new ConfigAPI();
|
||||
var _retryDelay = 2000;
|
||||
var _retrySaveSettingsDelay;
|
||||
var _retryLoadAllSettingsDelay;
|
||||
var _retryLoadSettingsDelay;
|
||||
var _retryResetSettingsDelay;
|
||||
|
||||
// ui elements
|
||||
var _element;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user