mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 09:44:55 +02:00
* installation of important stuff with help of AJAX
* installation will be now done with AJAX request (jQuery), that will instaltly notify about the status of the installation (no waiting without clue anymore) * install items & weapons on installation (before monsters)
This commit is contained in:
40
install/tools/installer.js
Normal file
40
install/tools/installer.js
Normal file
@@ -0,0 +1,40 @@
|
||||
function performInstall(url) {
|
||||
var lastResponseLength = false;
|
||||
var lastId = 1;
|
||||
|
||||
var ajaxRequest = $.ajax({
|
||||
type: 'get',
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: 'html',
|
||||
processData: false,
|
||||
xhrFields: {
|
||||
// Getting on progress streaming response
|
||||
onprogress: function (e) {
|
||||
var progressResponse;
|
||||
var response = e.currentTarget.response;
|
||||
progressResponse = response;
|
||||
if (lastResponseLength === false) {
|
||||
progressResponse = response;
|
||||
lastResponseLength = response.length;
|
||||
}
|
||||
else {
|
||||
progressResponse = response.substring(lastResponseLength);
|
||||
lastResponseLength = response.length;
|
||||
}
|
||||
|
||||
$('<div id="success-' + (lastId + 1) + '">' + progressResponse + '</div>').insertAfter("#success-" + lastId);
|
||||
lastId = lastId + 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
// On completed
|
||||
ajaxRequest.done(function(data) {
|
||||
$('#spinner').hide();
|
||||
});
|
||||
// On failed
|
||||
ajaxRequest.fail(function(error){
|
||||
console.log('Error: ', error);
|
||||
$('<span class="error">Error while doing AJAX request. Please refresh the page.</span>').insertAfter("#success-" + lastId);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user