forked from osTicket/osTicket-1.7
/
setup.js
64 lines (57 loc) · 1.85 KB
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
jQuery(function($) {
$("#overlay").css({
opacity : 0.3,
top : 0,
left : 0,
width : $(window).width(),
height : $(window).height()
});
$("#loading").css({
top : ($(window).height() / 3),
left : ($(window).width() / 2 - 160)
});
$('form#install').submit(function(e) {
$('input[type=submit]', this).attr('disabled', 'disabled');
$('#overlay, #loading').show();
return true;
});
$('form#upgrade').submit(function(e) {
e.preventDefault();
var form = $(this);
$('input[type=submit]', this).attr('disabled', 'disabled');
$('#overlay, #loading').show();
doTasks('upgrade.php',form.serialize());
return false;
});
function doTasks(url, data) {
function _lp(count) {
$.ajax({
type: 'GET',
url: 'p.php',
async: true,
cache: false,
data: data,
dataType: 'text',
success: function(res) {
if (res) {
$('#loading #msg').html(res);
}
},
statusCode: {
200: function() {
setTimeout(function() { _lp(count+1); }, 2);
},
304: function() {
$('#loading #msg').html("We're done... cleaning up!");
setTimeout(function() { location.href =url;}, 3000);
}
},
error: function() {
$('#loading #msg').html("Something went wrong");
setTimeout(function() { location.href =url;}, 1000);
}
});
};
_lp(0);
}
});