2 % my $jobnum = $cgi->param('jobnum');
3 % my $url = $cgi->param('url');
4 % my $message = $cgi->param('message');
5 % my $popup_url = $cgi->param('popup_url');
6 % my $formname = scalar($cgi->param('formname'));
7 % my $error_url = $cgi->param('error_url');
8 % my $reload_with_error = $cgi->param('reload_with_error');
15 <BODY BGCOLOR="#ccccff" onLoad="refreshStatus()">
17 <% include('/elements/xmlhttp.html',
18 'url' => $p.'misc/jsrsServer.html',
19 'subs' => [ 'job_status' ],
22 <SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/control.js"></SCRIPT>
23 <SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/imagelist.js"></SCRIPT>
24 <SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/progress.js"></SCRIPT>
25 <SCRIPT TYPE="text/javascript">
26 function refreshStatus () {
27 //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' );
29 job_status( '<% $jobnum %>', updateStatus );
31 function updateStatus( status_statustext ) {
33 //var Array = status_statustext.split("\n");
34 var statusArray = eval('(' + status_statustext + ')');
35 var status = statusArray[0];
36 var statustext = statusArray[1];
37 var actiontext = statusArray[2];
39 //if ( status == 'progress' ) {
40 //IE workaround, no i have no idea why
41 if ( status.indexOf('progress') > -1 ) {
42 document.getElementById("progress_message").innerHTML = actiontext + '...';
43 document.getElementById("progress_percent").innerHTML = statustext + '%';
46 //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' );
47 job_status( '<% $jobnum %>', updateStatus );
48 } else if ( status.indexOf('complete') > -1 ) {
52 % ? "window.top.location.href = \\'$url\\';"
55 document.getElementById("progress_message").innerHTML = "<% $message %>";
56 document.getElementById("progress_bar").innerHTML = '';
57 document.getElementById("progress_percent").innerHTML =
58 '<INPUT TYPE="button" VALUE="OK" onClick="<% $onClick %>">';
59 document.getElementById("progress_jobnum").innerHTML = '';
62 if ( parent.document.<%$formname%>.submit.disabled == true ) {
63 parent.document.<%$formname%>.submit.disabled=false;
69 window.top.location.href = '<% $url %>';
70 % } elsif ( $popup_url ) {
71 document.location.replace('<% $popup_url %>');
75 alert('job done but no url or message specified');
77 } else if ( status.indexOf('done') > -1 ) {
79 document.getElementById("progress_message").innerHTML = "Loading report";
80 document.getElementById("progress_bar").innerHTML = '';
81 document.getElementById("progress_percent").innerHTML = '';
82 document.getElementById("progress_jobnum").innerHTML = '';
83 window.top.location.href = statustext.substr(8, statustext.length-18);
85 } else if ( status.indexOf('error') > -1 ) {
87 % # default behavior: just close the popup
88 % my $onClick = 'parent.nd(1);';
89 % if ( $error_url ) { # then on clicking to confirm, redirect somewhere
90 % if ( $reload_with_error ) {
91 var encodedString = btoa(statustext);
93 window.top.location.href = '<% $error_url."&error_link=" %>'+encodedString;
96 % $onClick = "window.top.location.href = \\'$error_url\\';";
99 document.getElementById("progress_message").innerHTML = '<FONT SIZE="+1" COLOR="#FF0000">Error: ' + statustext + '</FONT>';
100 document.getElementById("progress_bar").innerHTML = '';
101 document.getElementById("progress_percent").innerHTML = '<INPUT TYPE="button" VALUE="OK" onClick="<% $onClick %>">';
102 document.getElementById("progress_jobnum").innerHTML = '';
103 if ( parent.document.<%$formname%>.submit.disabled == true ) {
104 parent.document.<%$formname%>.submit.disabled=false;
107 alert('XXX unknown status returned from server: ' + status);
115 <TD ALIGN="center" ID="progress_message">
116 Server processing job...
119 <TD ALIGN="center" ID="progress_bar">
120 <SCRIPT TYPE="text/javascript">
122 SEGS = new QImageList(4, 23, "<%$fsurl%>images/progressbar-empty.png", "<%$fsurl%>images/progressbar-full.png");
124 bar1 = new QProgress(null, "bar1", SEGS, 100);
131 <DIV ID="progress_percent">%</DIV>
134 <TD ALIGN="center" ID="progress_jobnum">
135 (progress of job #<% $jobnum %>)