forked from michmech/screenful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenful-job.js
28 lines (25 loc) · 1.13 KB
/
screenful-job.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
Screenful.Job={
start: function(){
Screenful.createEnvelope(true);
$("#envelope").html("<div id='middlebox'></div>");
$("#middlebox").append("<div class='message'>"+Screenful.Job.message+"</div>");
$("#middlebox").append("<div class='waiter'></div>");
$("#middlebox").append("<div class='progressMessage'></div>");
$("#middlebox").append("<div class='buttons'><button class='button finished' style='display: none'>"+Screenful.Loc.finished+"</button></div>");
$("#middlebox .buttons button").on("click", function(e){ window.location=Screenful.Job.awayUrl; });
Screenful.Job.batch();
},
batch: function(){
$.ajax({url: Screenful.Job.actionUrl, dataType: "json", method: "POST", data: Screenful.Job.state}).done(function(data){
Screenful.Job.state=data.state;
$("#middlebox .progressMessage").html(data.progressMessage);
if(data.finished) {
$("#middlebox .waiter").addClass("finished");
$("#middlebox .buttons button").show();
} else {
window.setTimeout(Screenful.Job.batch, 0); //500 ms = 0.5 second.
}
});
},
};
$(window).ready(Screenful.Job.start);