1 <!-- Background job progress indicator -->
2 <script type="text/javascript">
6 function updateJobProgress() {
7 $.getJSON("/cgi-bin/koha/tools/background-job-progress.pl?jobID=" + jobID, function(json) {
8 var percentage = Math.floor(100 * json.progress / json.job_size);
9 if (json.job_status == 'completed') {
12 $("#jobprogress").text(percentage + '%');
13 if (percentage < 100) {
14 setTimeout("updateJobProgress()",200);
21 function completeJob() {
22 savedForm.completedJobID.value = jobID;
26 // submit a background job with data
27 // supplied from form f and activate
29 function submitBackgroundJob(f) {
30 // check for background field
31 if (f.runinbackground) {
32 // set value of this hidden field for
35 f.mainformsubmit.disabled = true;
36 f.runinbackground.value = 'true';
38 // gather up form submission
40 $(':input', f).each(function() {
41 if (this.type == 'radio') {
43 inputs.push(this.name + '=' + escape(this.value));
45 } else if (this.type == 'button') {
48 inputs.push(this.name + '=' + escape(this.value));
53 // and submit the request
54 $("#jobstatus").show();
55 setTimeout("updateJobProgress()", 2000);
57 data: inputs.join('&'),
60 success: function(json) {
63 error: function(xml, textStatus) {
64 alert('Failed to submit form: ' + testStatus);
70 // background job support not enabled,
71 // so just do a normal form submission
75 //$("#jobstatus").show();
76 //setTimeout("updateJobProgress()",2000);
77 //updateJobProgress();