From 9e342300c380e29af1b9678f1a9604609e0061b6 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 10 Sep 2005 14:50:57 +0000 Subject: ajax-style xmlhttprequest state/county/country selector! --- httemplate/elements/xmlhttp.html | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 httemplate/elements/xmlhttp.html (limited to 'httemplate/elements/xmlhttp.html') diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html new file mode 100644 index 000000000..425e28e3d --- /dev/null +++ b/httemplate/elements/xmlhttp.html @@ -0,0 +1,65 @@ +<% + my ( $url, @subs ) = @_; + + $url .= ( ($url =~ /\?/) ? '&' : '?' ). + 'sub='; + +%> + + -- cgit v1.2.1 From 76161f1a2ae0f96470bed4089b00eff5abb16cff Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Sep 2005 08:13:36 +0000 Subject: 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... --- httemplate/elements/xmlhttp.html | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'httemplate/elements/xmlhttp.html') diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index 425e28e3d..41965ace2 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -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 @@ -38,11 +42,21 @@ // 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; -- cgit v1.2.1 From fbff7663ff6fb115bcd4dae2eb991b90339bf68d Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 24 Oct 2005 11:56:35 +0000 Subject: fix rate plan editing with new xmlhttp progressbar - use POST instead of GET. also optimize SQL on rate search screen --- httemplate/elements/xmlhttp.html | 77 +++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 28 deletions(-) (limited to 'httemplate/elements/xmlhttp.html') diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index 41965ace2..1199b69be 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -2,11 +2,11 @@ my ( %opt ) = @_; my $url = $opt{'url'}; - #my $action = exists $opt{'action'} ? $opt{'action'} : 'GET'; + my $method = exists($opt{'method'}) ? $opt{'method'} : 'GET'; #my @subs = @{ $opt{'subs'}; - $url .= ( ($url =~ /\?/) ? '&' : '?' ). - 'sub='; + $url .= ( ($url =~ /\?/) ? '&' : '?' ) + if $method eq 'GET'; %> @@ -33,43 +33,64 @@ <% foreach my $func ( @{$opt{'subs'}} ) { - my $furl = $url . uri_escape($func); + my $furl = $url; $furl =~ s/\"/\\\\\"/; #javascript escape %> function <%=$func%>() { - // count args; build URL - var url = "<%=$furl%>"; - var a = <%=$func%>.arguments; - var args; - var len; - if ( a && typeof a == 'object' && a[0].constructor == Array ) { - args = a[0]; + // count args; build URL + var url = "<%=$furl%>"; + var a = <%=$func%>.arguments; + + var args; + var len; + var content = 'sub=<%= uri_escape($func) %>'; + if ( a && typeof a == 'object' && a[0].constructor == Array ) { + args = a[0]; len = args.length - } else { + } 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; - //rs_debug("received " + x.responseText); - - if (xmlhttp.status != 200) { - alert(xmlhttp.status + " status connecting to " + url); - } else { + } + for (var i = 0; i < len; i++) + content = content + "&arg=" + escape(args[i]); + content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs + + if ( '<%=$method%>' == 'GET' ) { + url = url + content; + } + + //alert('<%=$method%> ' + url); + + var xmlhttp = rs_init_object(); + xmlhttp.open("<%=$method%>", url, true); + + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState != 4) + return; + + if (xmlhttp.status != 200) { + alert(xmlhttp.status + " status connecting to " + url); + } else { var data = xmlhttp.responseText; + //alert('received response: ' + data); a[a.length-1](data); } } - xmlhttp.send(null); + + if ( '<%=$method%>' == 'POST' ) { + + xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + xmlhttp.send(content); + + } else { + + xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); + xmlhttp.send(null); + + } + //rs_debug("x_$func_name url = " + url); //rs_debug("x_$func_name waiting.."); } -- cgit v1.2.1 From 92b2405b299bc60bc8bf6e594f7bd3f51645e124 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 4 Nov 2005 11:31:19 +0000 Subject: apply patch from Scott Edwards to show mason errors received from XMLHTTP requests --- httemplate/elements/xmlhttp.html | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'httemplate/elements/xmlhttp.html') diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index 1199b69be..4f4c5f53b 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -76,6 +76,15 @@ var data = xmlhttp.responseText; //alert('received response: ' + data); a[a.length-1](data); + if ( data.indexOf("System error") > -1 ) { + var w; + if ( w = window.open("about:blank") _ } + w.document.write(data); + } else { + // popup blocking? should use an overlib popup instead + alert("Error popup disabled; try disabling popup blocking to see"); + } + } } } -- cgit v1.2.1 From e254aa061c5ae8b838ea2b5af2e96f6e6f843d59 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 4 Nov 2005 11:31:50 +0000 Subject: apply patch from Scott Edwards to show mason errors received from XMLHTTP requests --- httemplate/elements/xmlhttp.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/elements/xmlhttp.html') diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index 4f4c5f53b..cf277fe1a 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -78,7 +78,7 @@ a[a.length-1](data); if ( data.indexOf("System error") > -1 ) { var w; - if ( w = window.open("about:blank") _ } + if ( w = window.open("about:blank") ) } w.document.write(data); } else { // popup blocking? should use an overlib popup instead -- cgit v1.2.1 From 705fca9417351f1fb86304ad95e33f61fb491587 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 4 Nov 2005 11:43:42 +0000 Subject: oops, typo applying patch --- httemplate/elements/xmlhttp.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/elements/xmlhttp.html') diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index cf277fe1a..28130e501 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -78,7 +78,7 @@ a[a.length-1](data); if ( data.indexOf("System error") > -1 ) { var w; - if ( w = window.open("about:blank") ) } + if ( w = window.open("about:blank") ) { w.document.write(data); } else { // popup blocking? should use an overlib popup instead -- cgit v1.2.1