blob: 6ab87e3f696aedac91666aa8a9e9b234c5b83328 (
plain)
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
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript">
var target_value;
var animation = null;
var delta = 1;
animate_progress_bar = function() {
var current_value = Number($(".gProgressBar div").css("width").replace("%", ""));
if (target_value > current_value) {
// speed up
delta = Math.min(delta + 0.04, 3);
} else {
// slow down
delta = Math.max(delta - 0.05, 1);
}
if (target_value == 100) {
$(".gProgressBar").progressbar("value", 100);
} else if (current_value != target_value || delta != 1) {
var new_value = Math.min(current_value + delta, target_value);
$(".gProgressBar").progressbar("value", new_value);
animation = setTimeout(function() { animate_progress_bar(target_value); }, 100);
} else {
animation = null;
delta = 1;
}
}
update = function() {
$.ajax({
url: "<?= url::site("admin/maintenance/run/$task->id?csrf=$csrf") ?>",
dataType: "json",
success: function(data) {
target_value = data.task.percent_complete;
if (!animation) {
animate_progress_bar();
}
$("#gStatus").html("" + data.task.status);
if (data.task.done) {
$("#gPauseButton").hide();
$("#gDoneButton").show();
} else {
setTimeout(update, 100);
}
}
});
}
$(".gProgressBar").progressbar({value: 0});
update();
dismiss = function() {
$.gallery_reload();
}
</script>
<div id="gProgress">
<h1> <?= $task->name ?> </h1>
<div class="gProgressBar"></div>
<div id="gStatus">
<?= t("Starting up...") ?>
</div>
<div>
<button id="gPauseButton" class="ui-state-default ui-corner-all" onclick="dismiss()"><?= t("Pause") ?></button>
<button id="gDoneButton" class="ui-state-default ui-corner-all" style="display: none" onclick="dismiss()"><?= t("Close") ?></button>
</div>
</div>
|