get rid of JSRS iframe foo for progress bar, use XMLHTTPRequest instead. really...
authorivan <ivan>
Sun, 25 Sep 2005 08:13:36 +0000 (08:13 +0000)
committerivan <ivan>
Sun, 25 Sep 2005 08:13:36 +0000 (08:13 +0000)
15 files changed:
CREDITS
Changes.1.5.8
FS/FS/UI/Web.pm
JSRS-LICENSE [deleted file]
README.1.5.7
httemplate/docs/install.html
httemplate/docs/upgrade10.html
httemplate/edit/cust_main/select-country.html
httemplate/edit/cust_main/select-county.html
httemplate/edit/process/part_svc.cgi
httemplate/edit/process/rate.cgi
httemplate/elements/jsrsServer.html
httemplate/elements/progress-init.html
httemplate/elements/progress-popup.html
httemplate/elements/xmlhttp.html

diff --git a/CREDITS b/CREDITS
index 450f267..bec9702 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -110,8 +110,9 @@ other fixes.
 Charles A Beasley <cbeasley@noment.net> contributed quota editing for the
 Infostreet export.
 
-Richard Siddall <richard.siddall@elirion.net> sent in Mason fixes and other
-things I'm probably forgetting.
+Richard Siddall <richard.siddall@elirion.net> sent in Mason fixes, fixed lots
+of typos, mod_perl 2.0 work, RPM packaging and other things I'm probably
+forgetting.
 
 Contains "JS Calendar" <http://dynarch.com/mishoo/calendar.epl>
 by Mihai Bazon <mishoo@infoiasi.ro> licensed under the terms of the GNU LGPL.
@@ -137,11 +138,6 @@ released with 1.4.2beta1 and 1.5.0pre6.
 Troy Hammonds <troyh@netsignia.net> sent in RADIUS session history viewing,
 many bugfixes and other things I'm probably forgetting.
 
-Contains the "Javascript Remote Scripting (JSRS)" client library
-<http://www.ashleyit.com/rs/main.htm> by Brent Ashley <brent@ashleyit.com>
-licensed under the "No Nonsense Copyright and License" (see the included
-JSRS-LICENSE file).
-
 Contains the QLIB JavaScript library <http://qlib.quazzle.com/> by 
 Quazzle.com, Serge Dolgov, licensed under the terms of the GNU GPL.
 
index efb91ba..f8066cc 100644 (file)
@@ -5,6 +5,14 @@
 - add active/suspended/cancelled customer packages to agent browse
 - add export to everyone.net outsource mail service
 - add native Radiator export
-- added agent/taxclass gateway overrides
+- added agent/taxclass/card type-specific gateway overrides for people with
+  multiple payment gateways for different resellers, taxclasses and/or card
+  types
 - re-did billing section of customer edit and added switch/solo support
 - add cpanel export
+- added prepaid packages that set the RADIUS "Expiration" attribute and
+  auto-suspend on their next bill date
+- added banned card table and option to send customer cards there on cancel
+- moved to XMLHttpRequest instead of hidden iframe transport for progress bar,
+  should be more efficient and improve compatibility with Konq and maybe other
+  browsers?
index 18e841e..213a219 100644 (file)
@@ -133,12 +133,12 @@ use strict;
 use vars qw(@ISA $DEBUG);
 use Storable qw(nfreeze);
 use MIME::Base64;
-use JavaScript::RPC::Server::CGI;
+#use JavaScript::RPC::Server::CGI;
 use FS::UID;
 use FS::Record qw(qsearchs);
 use FS::queue;
 
-@ISA = qw( JavaScript::RPC::Server::CGI );
+#@ISA = qw( JavaScript::RPC::Server::CGI );
 $DEBUG = 0;
 
 sub new {
@@ -146,6 +146,7 @@ sub new {
         my $self  = {
                 env => {},
                 job => shift,
+                cgi => shift,
         };
 
         bless $self, $class;
@@ -153,6 +154,35 @@ sub new {
         return $self;
 }
 
+sub process {
+
+  my $self = shift;
+
+  my $cgi = $self->{'cgi'};
+
+  # XXX this should parse JSON foo and build a proper data structure
+  my @args = $cgi->param('arg');
+
+  my $sub = $cgi->param('sub'); #????
+
+  warn "FS::UI::Web::JSRPC::process:\n".
+       "  cgi=$cgi\n".
+       "  sub=$sub\n".
+       "  args=".join(', ',@args)."\n"
+    if $DEBUG;
+
+  if ( $sub eq 'start_job' ) {
+
+    $self->start_job(@args);
+
+  } elsif ( $sub eq 'job_status' ) {
+
+    $self->job_status(@args);
+
+  }
+
+}
+
 sub start_job {
   my $self = shift;
 
@@ -193,7 +223,10 @@ sub start_job {
   my $error = $job->insert( '_JOB', encode_base64(nfreeze(\%param)) );
 
   if ( $error ) {
-    $error;
+    $error;  #this doesn't seem to be handled well,
+             # will trigger "illegal jobnum" below?
+             # (should never be an error inserting the job, though, only thing
+             #  would be Pg f%*kage)
   } else {
     $job->jobnum;
   }
@@ -203,7 +236,7 @@ sub start_job {
 sub job_status {
   my( $self, $jobnum ) = @_; #$url ???
 
-  sleep 5; #could use something better...
+  sleep 1; # XXX could use something better...
 
   my $job;
   if ( $jobnum =~ /^(\d+)$/ ) {
@@ -222,13 +255,23 @@ sub job_status {
     @return = ( 'error', $job ? $job->statustext : $jobnum );
   }
 
-  join("\n",@return);
+  #join("\n",@return);
 
-}
+  #XXX should use JSON!
+  @return = map {
+    s/\\/\\\\/g;
+    s/\n/\\n/g;
+    s/"/\"/g;
+    $_
+  } @return;
+  
+  '[ '. join(', ', map { qq("$_") } @return). " ]\n";
 
-sub get_new_query {
-  FS::UID::cgi();
 }
 
+#sub get_new_query {
+#  FS::UID::cgi();
+#}
+
 1;
 
diff --git a/JSRS-LICENSE b/JSRS-LICENSE
deleted file mode 100644 (file)
index fd14984..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-\r
-No Nonsense Copyright and License for JSRS JavaScript Remote Scripting\r
-======================================================================\r
-\r
-Copyright:\r
-\r
-This JSRS stuff was written by me.  I find it useful.  Others find it useful. \r
-You are welcome to use it, modify it to suit your needs, distribute it as you \r
-see fit.  I'm happy if you use it for personal stuff or for commercial gain.\r
-\r
-The only thing you can't do is to restrict anyone else from using it however \r
-they see fit.  You may not copyright it yourself or change the rules I have \r
-set on how it can be used.\r
-\r
-JSRS Javascript Remote Scripting Copyright (C) 2001 by Brent Ashley\r
-\r
-License:\r
-\r
-You can use this however you like.  I make no guarantees whatsoever that it \r
-will suit your purpose.  You take full responsibility for getting it working \r
-properly and for any implications of its failure or inability to satisfy your \r
-every need.\r
-\r
-======================================================================\r
-\r
-email inquiries: jsrs@megahuge.com\r
-\r
-\r
-\r
index adfffea..e890f01 100644 (file)
@@ -187,9 +187,8 @@ dbdef-create username
 create-history-tables username rate rate_detail rate_region rate_prefix reg_code reg_code_pkg
 dbdef-create username
 
-install Javascript::RPC (JavaScript::RPC::Server::CGI), Text::CSV_XS,
-Spreadsheet::WriteExcel, IO-stringy (IO::Scalar), Frontier::RPC
-(Frontier::RPC2), MIME::Entity (MIME-tools) and IPC::Run3
+install Text::CSV_XS, Spreadsheet::WriteExcel, IO-stringy (IO::Scalar),
+Frontier::RPC (Frontier::RPC2), MIME::Entity (MIME-tools) and IPC::Run3
 
 afterwords (for installs w/integrated RT):
 install HTML::Scrubber, Text::Quoted and Tree::Simple
index 72b1214..d89ea3f 100644 (file)
@@ -61,7 +61,6 @@ Before installing, you need:
       <li><a href="http://search.cpan.org/dist/Chart">Chart</a>
       <li><a href="http://search.cpan.org/dist/Crypt-PasswdMD5">Crypt::PasswdMD5</a>
       <li><a href="http://search.cpan.org/dist/Locale-SubCountry">Locale::SubCountry</a>
-      <li><a href="http://search.cpan.org/dist/JavaScript-RPC">JavaScript::RPC (JavaScript::RPC::Server::CGI)</a>
       <li><a href="http://search.cpan.org/dist/Frontier-RPC">Frontier::RPC</a>
       <li><a href="http://search.cpan.org/dist/Text-CSV_XS">Text::CSV_XS</a>
       <li><a href="http://search.cpan.org/dist/Spreadsheet-WriteExcel">Spreadsheet::WriteExcel</a>
index 98a457a..fb51bfb 100644 (file)
@@ -18,8 +18,7 @@ install HTML::Widgets::SelectLayers 0.05
 - In httpd.conf, change &lt;Files ~ \.cgi&gt; to  &lt;Files ~ (\.cgi|\.html)&gt;
 - In httpd.conf, change <b>AddHandler perl-script .cgi</b> or <b>SetHandler perl-script</b> to <b>AddHandler perl-script .cgi .html</b>
 
-install NetAddr::IP, Chart::Base, Locale::SubCountry, 
-JavaScript::RPC (JavaScript::RPC::Server::CGI), Text::CSV_XS, 
+install NetAddr::IP, Chart::Base, Locale::SubCountry, Text::CSV_XS, 
 Spreadsheet::WriteExcel, IO-stringy (IO::Scalar), Frontier::RPC
 (Frontier::RPC2), MIME::Entity (MIME-tools) and IPC::Run3
 <!-- and Crypt::YAPassGen-->
index 44f4f0a..014effd 100644 (file)
 
 %>
 
-<%= include('/elements/xmlhttp.html', $p.'misc/states.cgi', $opt{'prefix'}. 'get_states') %>
+<%= include('/elements/xmlhttp.html',
+              'url'  => $p.'misc/states.cgi',
+              'subs' => [ $opt{'prefix'}. 'get_states' ],
+           )
+%>
 
 <SCRIPT TYPE="text/javascript">
 
index 70a8f94..3de380b 100644 (file)
 
 <% if ( $countyflag ) { %>
 
-  <%= include('/elements/xmlhttp.html', $p.'misc/counties.cgi', $opt{'prefix'}. 'get_counties' ) %>
+  <%= include('/elements/xmlhttp.html',
+                'url'  => $p.'misc/counties.cgi',
+                'subs' => [ $opt{'prefix'}. 'get_counties' ],
+             )
+%>
   
   <SCRIPT TYPE="text/javascript">
   
index 664e521..b92b627 100755 (executable)
@@ -1,4 +1,3 @@
 <%
-my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process';
-$server->process;
-%>
+  my $server = new FS::UI::Web::JSRPC 'FS::part_svc::process', $cgi;
+%><%= $server->process %>
index 005caf9..0030b57 100755 (executable)
@@ -1,4 +1,3 @@
 <%
-my $server = new FS::UI::Web::JSRPC 'FS::rate::process';
-$server->process;
-%>
+  my $server = new FS::UI::Web::JSRPC 'FS::rate::process';
+%><%= $server->process %>
index d6d5370..fd6dc54 100644 (file)
@@ -1,4 +1,3 @@
 <%
-my $server = new FS::UI::Web::JSRPC;
-$server->process;
-%>
+  my $server = new FS::UI::Web::JSRPC '', $cgi;
+%><%= $server->process %>
index 472a172..fb40840 100644 (file)
   }
 %>
 
-<SCRIPT TYPE="text/javascript" SRC="../elements/jsrsClient.js"></SCRIPT>
+<%= include('/elements/xmlhttp.html',
+              '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">
@@ -54,8 +58,10 @@ function <%=$key%>process () {
     }
   }
 
-  jsrsPOST = true;
-  jsrsExecute( '<%= $action %>', <%=$key%>myCallback, 'start_job', Hash );
+  // jsrsPOST = true;
+  // jsrsExecute( '<%= $action %>', <%=$key%>myCallback, 'start_job', Hash );
+
+  start_job( Hash, <%=$key%>myCallback );
 
 }
 
index 20bb5fc..200f97d 100644 (file)
   </HEAD>
   <BODY BGCOLOR="#ccccff" onLoad="refreshStatus()">
 
-<SCRIPT TYPE="text/javascript" SRC="../elements/jsrsClient.js"></SCRIPT>
+<%= include('/elements/xmlhttp.html',
+              'url'  => $p.'elements/jsrsServer.html',
+              'subs' => [ 'job_status' ],
+           )
+%>
 <SCRIPT TYPE="text/javascript" src="../elements/qlib/control.js"></SCRIPT>
 <SCRIPT TYPE="text/javascript" src="../elements/qlib/imagelist.js"></SCRIPT>
 <SCRIPT TYPE="text/javascript" src="../elements/qlib/progress.js"></SCRIPT>
 <SCRIPT TYPE="text/javascript">
 function refreshStatus () {
-  jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' );
+  //jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' );
+
+  job_status( '<%= $jobnum %>', updateStatus );
 }
 function updateStatus( status_statustext ) {
-  var Array = status_statustext.split("\n");
-  var status = Array[0];
-  var statustext = Array[1];
+
+  //var Array = status_statustext.split("\n");
+  var statusArray = eval('(' + status_statustext + ')');
+  var status = statusArray[0];
+  var statustext = statusArray[1];
+
   //if ( status == 'progress' ) {
   //IE workaround, no i have no idea why
   if ( status.indexOf('progress') > -1 ) {
     document.getElementById("progress_percent").innerHTML = statustext + '%';
     bar1.set(statustext);
     bar1.update;
-    jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' );
+    //jsrsExecute( '<%=$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<%= $jobnum %>' );
+    job_status( '<%= $jobnum %>', updateStatus );
   } else if ( status.indexOf('complete') > -1 ) {
 <% if ( $message ) { %>
     document.getElementById("progress_message").innerHTML = "<%= $message %>";
index 425e28e..41965ac 100644 (file)
@@ -1,5 +1,9 @@
 <%
-  my ( $url, @subs ) = @_;
+  my ( %opt ) = @_;
+
+  my $url = $opt{'url'};
+  #my $action = exists $opt{'action'} ? $opt{'action'} : 'GET';
+  #my @subs = @{ $opt{'subs'};
 
   $url .= ( ($url =~ /\?/) ? '&' : '?' ).
           'sub=';
@@ -27,7 +31,7 @@
 
   }
 
-  <% foreach my $func (@subs) { 
+  <% foreach my $func ( @{$opt{'subs'}} ) { 
 
        my $furl = $url . uri_escape($func);
        $furl =~ s/\"/\\\\\"/; #javascript escape
        // count args; build URL
        var url = "<%=$furl%>";
        var a = <%=$func%>.arguments;
-       for (var i = 0; i < a.length-1; i++) 
-           url = url + "&arg=" + escape(a[i]);
+       var args;
+       var len;
+       if ( a && typeof a  == 'object'  && a[0].constructor == Array ) {
+           args = a[0];
+            len = args.length
+       } else {
+            args = a;
+            len = args.length - 1;
+       }
+       for (var i = 0; i < len; i++) 
+           url = url + "&arg=" + escape(args[i]);
        url = url.replace( /[+]/g, '%2B'); // fix the unescaped plus signs 
        var xmlhttp = rs_init_object();
        xmlhttp.open("GET", url, true);
+       xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState != 4) 
                return;