summaryrefslogtreecommitdiff
path: root/httemplate/elements/progress-init.html
blob: 7844f56788ecdf6af889976a7f7cdcdf411f515b (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<%
  my( $formname, $fields, $action, $url_or_message, $key ) = @_;
  $key = '' unless defined $key;

  my $url_or_message_link;
  if ( ref($url_or_message) ) { #its a message or something
    $url_or_message_link =
      'message='. uri_escape( $url_or_message->{'message'} )
  } else {
    $url_or_message_link = "url=$url_or_message";
  }
%>

<%= include('/elements/xmlhttp.html',
              'method' => 'POST',
              'url'    => $action,
              'subs'   => [ 'start_job' ],
           )
%>
<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT>
<SCRIPT TYPE="text/javascript">
function OLiframeContent(src, width, height, name) {
  return ('<iframe src="'+src+'" width="'+width+'" height="'+height+'"'
   +(name?' name="'+name+'" id="'+name+'"':'')+' scrolling="auto">'
   +'<div>[iframe not supported]</div></iframe>');
}

function <%=$key%>process () {

  //alert('<%=$key%>process for form <%=$formname%>');

  document.<%=$formname%>.submit.disabled=true;

  overlib( 'Submitting job to server...', WIDTH, 432, HEIGHT, 136, CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 );

  var Hash = new Array();
  var x = 0;
  var fieldName;
  for (var i = 0; i<document.<%=$formname%>.elements.length; i++) {
    field  = document.<%=$formname%>.elements[i];
    if ( <%= join(' || ', map { "(field.name.indexOf('$_') > -1)" } @$fields ) %>
       )
    {
        if ( field.type == 'select-multiple' ) {
          //alert('select-multiple ' + field.name);
          for (var j=0; j < field.options.length; j++) {
            if ( field.options[j].selected ) {
              //alert(field.name + ' => ' + field.options[j].value);
              Hash[x++] = field.name;
              Hash[x++] = field.options[j].value;
            }
          }
        } else if (    ( field.type != 'radio'  && field.type != 'checkbox' )
                    || ( ( field.type == 'radio' || field.type == 'checkbox' )
                         && document.<%=$formname%>.elements[i].checked
                       )
                  )
        {
          Hash[x++] = field.name;
          Hash[x++] = field.value;
        }
    }
  }

  // jsrsPOST = true;
  // jsrsExecute( '<%= $action %>', <%=$key%>myCallback, 'start_job', Hash );

  //alert('start_job( ' + Hash + ', <%=$key%>myCallback )' );
  //alert('start_job()' );
  start_job( Hash, <%=$key%>myCallback );

}

function <%=$key%>myCallback( jobnum ) {

  overlib( OLiframeContent('<%=$p%>elements/progress-popup.html?jobnum=' + jobnum + ';<%=$url_or_message_link%>;formname=<%=$formname%>' , 432, 136, 'progress_popup'), CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 );

}

</SCRIPT>