1 <!-- Background job progress indicator -->
2 <script type="text/javascript">
4 var backgroundJobProgressTimer = 0;
7 var inBackgroundJobProgressTimer = false;
8 function updateJobProgress() {
9 if (inBackgroundJobProgressTimer) {
12 inBackgroundJobProgressTimer = true;
13 $.getJSON("/cgi-bin/koha/tools/background-job-progress.pl?jobID=" + jobID, function(json) {
14 var percentage = Math.floor(100 * json.progress / json.job_size);
15 if (json.job_status == 'completed') {
18 $("#jobprogress").text(percentage);
19 if (percentage == 100) {
20 clearInterval(backgroundJobProgressTimer); // just in case form submission fails
23 inBackgroundJobProgressTimer = false;
27 function completeJob() {
28 savedForm.completedJobID.value = jobID;
32 // submit a background job with data
33 // supplied from form f and activate
35 function submitBackgroundJob(f) {
36 // check for background field
37 if (f.runinbackground) {
38 // set value of this hidden field for
41 f.mainformsubmit.disabled = true;
42 f.runinbackground.value = 'true';
44 // gather up form submission
46 $(':input', f).each(function() {
47 if (this.type == 'radio') {
49 inputs.push(this.name + '=' + escape(this.value));
51 } else if (this.type == 'button') {
54 inputs.push(this.name + '=' + escape(this.value));
59 // and submit the request
60 $("#jobstatus").show();
62 data: inputs.join('&'),
65 success: function(json) {
67 inBackgroundJobProgressTimer = false;
68 backgroundJobProgressTimer = setInterval("updateJobProgress()", 500);
70 error: function(xml, textStatus) {
71 alert('Failed to submit form: ' + testStatus);
77 // background job support not enabled,
78 // so just do a normal form submission