Skip to content

Commit

Permalink
refactor: add the loadLatestCore helper to config.macros.upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
YakovL committed Jun 27, 2022
1 parent 35d08d3 commit 118316e
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions js/Upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ config.macros.upgrade.getSourceURL = function()
return config.options.txtUpgradeCoreURI || config.macros.upgrade.source;
};

//# onSuccess: function(coreAsText, textStatus, jqXHR)
//# onError: function(jqXHR, textStatus, errorThrown)
config.macros.upgrade.loadLatestCore = function(onSuccess, onError)
{
ajaxReq({
type: "GET",
url: this.getSourceURL(),
processData: false,
success: onSuccess,
error: onError
});
}

config.macros.upgrade.handler = function(place)
{
var w = new Wizard();
Expand Down Expand Up @@ -47,19 +60,11 @@ config.macros.upgrade.onClickUpgrade = function(e)
w.setValue("backupPath", backupPath);

w.setButtons([], me.statusLoadingCore);
var sourceURL = me.getSourceURL();
var options = {
type:"GET",
url:sourceURL,
processData:false,
success:function(data, textStatus, jqXHR) {
me.onLoadCore(true, w, jqXHR.responseText, sourceURL, jqXHR);
},
error:function(jqXHR, textStatus, errorThrown) {
me.onLoadCore(false, w, null, sourceURL, jqXHR);
}
};
ajaxReq(options);
me.loadLatestCore(function(data, textStatus, jqXHR) {
me.onLoadCore(true, w, jqXHR.responseText, sourceURL, jqXHR);
}, function(jqXHR, textStatus, errorThrown) {
me.onLoadCore(false, w, null, sourceURL, jqXHR);
});
return false;
};

Expand Down

0 comments on commit 118316e

Please sign in to comment.