3 In misc/something.html:
6 <INPUT TYPE="hidden" NAME="recordnum" VALUE="42">
7 <INPUT TYPE="hidden" NAME="what_to_do" VALUE="delete">
8 <% include( '/elements/progress-init.html',
10 [ 'recordnum', 'what_to_do' ],
11 $p.'misc/process_something.html',
12 { url => $p.'where_to_go_next.html' },
13 #or { message => 'Finished!' },
16 <SCRIPT TYPE="text/javascript>process();</SCRIPT>
18 In misc/process_something.html:
21 my $server = FS::UI::Web::JSRPC->new('FS::something::process_whatever', $cgi);
23 <% $server->process %>
27 sub process_whatever { #class method
29 my $param = thaw(base64_decode(shift));
30 # param = { 'recordnum' => 42, 'what_to_do' => delete }
31 # make use of this as you like
33 $job->update_statustext(20);
35 $job->update_statustext(40);
37 $job->update_statustext(60);
39 return 'BLAH BLAH NOBODY WILL EVER SEE THIS RETURN VALUE';
42 I am not responsible for errors in the above documentation.
45 <% include('/elements/xmlhttp.html',
48 'subs' => [ 'start_job' ],
53 <% include('/elements/init_overlib.html') %>
55 <SCRIPT TYPE="text/javascript">
57 function <%$key%>process () {
59 //alert('<%$key%>process for form <%$formname%>');
61 if ( document.<%$formname%>.submit.disabled == false ) {
62 document.<%$formname%>.submit.disabled=true;
65 overlib( 'Submitting job to server...', WIDTH, 444, HEIGHT, 168, CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 );
67 var Hash = new Array();
70 for (var i = 0; i<document.<%$formname%>.elements.length; i++) {
71 field = document.<%$formname%>.elements[i];
72 if ( <% join(' || ', map { "(field.name.indexOf('$_') > -1)" } @$fields ) %>
75 if ( field.type == 'select-multiple' ) {
76 //alert('select-multiple ' + field.name);
77 for (var j=0; j < field.options.length; j++) {
78 if ( field.options[j].selected ) {
79 //alert(field.name + ' => ' + field.options[j].value);
80 Hash[x++] = field.name;
81 Hash[x++] = field.options[j].value;
84 } else if ( ( field.type != 'radio' && field.type != 'checkbox' )
85 || ( ( field.type == 'radio' || field.type == 'checkbox' )
86 && document.<%$formname%>.elements[i].checked
90 Hash[x++] = field.name;
91 Hash[x++] = field.value;
97 // jsrsExecute( '<% $action %>', <%$key%>myCallback, 'start_job', Hash );
99 //alert('start_job( ' + Hash + ', <%$key%>myCallback )' );
100 //alert('start_job()' );
101 <%$key%>start_job( Hash, <%$key%>myCallback );
105 function <%$key%>myCallback( jobnum ) {
107 overlib( OLiframeContent('<%$p%>elements/progress-popup.html?jobnum=' + jobnum + ';<%$url_or_message_link%>;formname=<%$formname%>' , 444, 168, '<% $popup_name %>'), CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 );
115 my( $formname, $fields, $action, $url_or_message, $key ) = @_;
116 $key = '' unless defined $key;
118 my $url_or_message_link;
119 if ( ref($url_or_message) ) { #its a message or something
120 $url_or_message_link = 'message='. uri_escape( $url_or_message->{'message'} );
121 $url_or_message_link .= ';url='. uri_escape( $url_or_message->{'url'} )
122 if $url_or_message->{'url'};
124 $url_or_message_link = "url=$url_or_message";
127 #stupid safari is caching the "location" of popup iframs, and submitting them
128 #instead of displaying them. this should prevent that.
129 my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32;