From 76161f1a2ae0f96470bed4089b00eff5abb16cff Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Sep 2005 08:13:36 +0000 Subject: [PATCH] get rid of JSRS iframe foo for progress bar, use XMLHTTPRequest instead. really should have done that in the first place. JSON will wait until another day... --- CREDITS | 10 ++--- Changes.1.5.8 | 10 ++++- FS/FS/UI/Web.pm | 59 +++++++++++++++++++++++---- JSRS-LICENSE | 29 ------------- README.1.5.7 | 5 +-- httemplate/docs/install.html | 1 - httemplate/docs/upgrade10.html | 3 +- httemplate/edit/cust_main/select-country.html | 6 ++- httemplate/edit/cust_main/select-county.html | 6 ++- httemplate/edit/process/part_svc.cgi | 5 +-- httemplate/edit/process/rate.cgi | 5 +-- httemplate/elements/jsrsServer.html | 5 +-- httemplate/elements/progress-init.html | 12 ++++-- httemplate/elements/progress-popup.html | 22 +++++++--- httemplate/elements/xmlhttp.html | 22 ++++++++-- 15 files changed, 125 insertions(+), 75 deletions(-) delete mode 100644 JSRS-LICENSE diff --git a/CREDITS b/CREDITS index 450f26704..bec9702a5 100644 --- a/CREDITS +++ b/CREDITS @@ -110,8 +110,9 @@ other fixes. Charles A Beasley contributed quota editing for the Infostreet export. -Richard Siddall sent in Mason fixes and other -things I'm probably forgetting. +Richard Siddall 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" by Mihai Bazon licensed under the terms of the GNU LGPL. @@ -137,11 +138,6 @@ released with 1.4.2beta1 and 1.5.0pre6. Troy Hammonds sent in RADIUS session history viewing, many bugfixes and other things I'm probably forgetting. -Contains the "Javascript Remote Scripting (JSRS)" client library - by Brent Ashley -licensed under the "No Nonsense Copyright and License" (see the included -JSRS-LICENSE file). - Contains the QLIB JavaScript library by Quazzle.com, Serge Dolgov, licensed under the terms of the GNU GPL. diff --git a/Changes.1.5.8 b/Changes.1.5.8 index efb91ba55..f8066cc99 100644 --- a/Changes.1.5.8 +++ b/Changes.1.5.8 @@ -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? diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm index 18e841e83..213a21975 100644 --- a/FS/FS/UI/Web.pm +++ b/FS/FS/UI/Web.pm @@ -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 index fd14984a9..000000000 --- a/JSRS-LICENSE +++ /dev/null @@ -1,29 +0,0 @@ - -No Nonsense Copyright and License for JSRS JavaScript Remote Scripting -====================================================================== - -Copyright: - -This JSRS stuff was written by me. I find it useful. Others find it useful. -You are welcome to use it, modify it to suit your needs, distribute it as you -see fit. I'm happy if you use it for personal stuff or for commercial gain. - -The only thing you can't do is to restrict anyone else from using it however -they see fit. You may not copyright it yourself or change the rules I have -set on how it can be used. - -JSRS Javascript Remote Scripting Copyright (C) 2001 by Brent Ashley - -License: - -You can use this however you like. I make no guarantees whatsoever that it -will suit your purpose. You take full responsibility for getting it working -properly and for any implications of its failure or inability to satisfy your -every need. - -====================================================================== - -email inquiries: jsrs@megahuge.com - - - diff --git a/README.1.5.7 b/README.1.5.7 index adfffea55..e890f01bc 100644 --- a/README.1.5.7 +++ b/README.1.5.7 @@ -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 diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index 72b1214ec..d89ea3f04 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -61,7 +61,6 @@ Before installing, you need:
  • Chart
  • Crypt::PasswdMD5
  • Locale::SubCountry -
  • JavaScript::RPC (JavaScript::RPC::Server::CGI)
  • Frontier::RPC
  • Text::CSV_XS
  • Spreadsheet::WriteExcel diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html index 98a457ae6..fb51bfb8e 100644 --- a/httemplate/docs/upgrade10.html +++ b/httemplate/docs/upgrade10.html @@ -18,8 +18,7 @@ install HTML::Widgets::SelectLayers 0.05 - In httpd.conf, change <Files ~ \.cgi> to <Files ~ (\.cgi|\.html)> - In httpd.conf, change AddHandler perl-script .cgi or SetHandler perl-script to AddHandler perl-script .cgi .html -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 diff --git a/httemplate/edit/cust_main/select-country.html b/httemplate/edit/cust_main/select-country.html index 44f4f0a55..014effd66 100644 --- a/httemplate/edit/cust_main/select-country.html +++ b/httemplate/edit/cust_main/select-country.html @@ -10,7 +10,11 @@ %> -<%= 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' ], + ) +%> +<%= include('/elements/xmlhttp.html', + 'url' => $action, + 'subs' => [ 'start_job' ], + ) +%> +<%= include('/elements/xmlhttp.html', + 'url' => $p.'elements/jsrsServer.html', + 'subs' => [ 'job_status' ], + ) +%>