diff -uNr sajax-0.10/Changes.txt sajax-0.12/Changes.txt --- sajax-0.10/Changes.txt Mon Mar 21 19:35:36 2005 +++ sajax-0.12/Changes.txt Mon Jan 30 02:52:25 2006 @@ -1,6 +1,12 @@ SAJAX CHANGELOG --------------- +Sajax version 0.12 (January 30, 2006) + +* [php] Numerous improvements to serialization, support for varied PHP + setups, addition of sajax_cancel(). +* [asp] Removed due to serious bugs + Sajax version 0.10 (March 21, 2005) * [php] Support for POST instead of just GET. Set $sajax_request_type. diff -uNr sajax-0.10/Todo.txt sajax-0.12/Todo.txt --- sajax-0.10/Todo.txt Wed Mar 30 13:36:35 2005 +++ sajax-0.12/Todo.txt Wed Aug 17 12:28:17 2005 @@ -1,14 +1,21 @@ SAJAX TO DO LIST ---------------- -* Support for "options" such as post-to-an-ID and POST/GET submit. +* Fix http://www.modernmethod.com/sajax/forum/viewtopic.php?p=308 * Return false if the object could not be created. -* Make the whole darn thing an object -* Encode/serialize array elements +* Make the whole darn thing an object * Add J2EE module * Apply Julien Grossiord's port non-80 patch. +* Apply Steve Smith (ND)'s ColdFusion POST patch. +* Better whitespace handling +* Test if a function exists before allowing you to export it +* Add Kae's IFRAME patch. +* Add C# support. +* All-numeric array indices -> JS array, not object. THINGS THAT WERE TO DO AND ARE NOW TO DONE ------------------------------------------ +* Encode/serialize array elements +* Support for "options" such as post-to-an-ID and POST/GET submit. * Added sajax_set_remote_url or something along those lines instead of $REQUEST_URI * Support POST diff -uNr sajax-0.10/asp/Readme.txt sajax-0.12/asp/Readme.txt --- sajax-0.10/asp/Readme.txt Mon Mar 21 18:36:14 2005 +++ sajax-0.12/asp/Readme.txt Mon Jan 30 02:40:26 2006 @@ -1,4 +1,3 @@ -SAJAX ASP(JScript) BACKEND --------------------------- +ASP support has been temporarily removed due to bugs. It will be back soon. -Contributed and copyighted by Jared Nuzzolillo (http://www.protoscript.net/). +- tlack diff -uNr sajax-0.10/asp/example_multiply.asp sajax-0.12/asp/example_multiply.asp --- sajax-0.10/asp/example_multiply.asp Fri Mar 18 13:44:16 2005 +++ sajax-0.12/asp/example_multiply.asp Wed Dec 31 19:00:00 1969 @@ -1,77 +0,0 @@ -<%@ Language=JScript %> - - -<% - - function multiply(x, y) { - return x * y; - } - - function add(x, y, z) { - return x + y + z; - } - - sajax = new Sajax(); -// sajax.debug_mode = true; - sajax.export_function("multiply","add"); - sajax.handle_client_request(); - -%> - - - Multiplier - - - - - * - - = - - -
- try adding some strings, eg: - - + - - + - - = - - - - diff -uNr sajax-0.10/asp/sajax.asp sajax-0.12/asp/sajax.asp --- sajax-0.10/asp/sajax.asp Fri Mar 18 13:43:12 2005 +++ sajax-0.12/asp/sajax.asp Wed Dec 31 19:00:00 1969 @@ -1,186 +0,0 @@ -<% - -function r(str) -{ - Response.write("
-"+str+"-
") -} - - function Sajax(debug_mode) - { - this.debug_mode = debug_mode||false; - this.export_list = []; - this.js_has_been_shown = false; - - this.handle_client_request = function() - { - func_name = Request.QueryString("rs"); - if(!func_name||String(func_name)=="undefined") return false - - //bust cache - Response.AddHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT") - //always modified - Response.AddHeader("Last-Modified", new Date().toGMTString().replace(/UTC/,"GMT")) - //HTTP/1.1 - Response.AddHeader("Cache-Control", "no-cache, must-revalidate") - //HTTP/1.0 - Response.AddHeader("Pragma", "no-cache") - - - - if(this.export_list[func_name]=="undefined") - { - result = "-"+func_name+" is not callable"; - //if(this.debug_mode) Response.write("-"+func_name+" is not callable"); - } - else - { - rsargs_raw = Request.QueryString("rsargs[]") - - rsargs = [] - for(rs_i=1;rs_i<=rsargs_raw.Count;rs_i++) - { - rsargs[rs_i-1]=rsargs_raw(rs_i) - } - - // if(this.debug_mode) Response.write("calling " + func_name + "(" + - // rsargs.join(",")+")") - - eval_str = this.export_list[func_name]+"("+rsargs+")" - - try - { - result = "+"+eval(eval_str); - } - catch(e) - { - result = "-"+e.message+" (x_"+eval_str+")"; - } - } - - Response.write(result+"[sajax_result________end]]") - //exit() - } - - this.show_common_js = function() - { - js_debug_mode = this.debug_mode - js_string_out = " // remote scripting library\n" + - " // (c) copyright 2005 modernmethod, inc\n" + - " var rs_debug_mode = "+js_debug_mode+";\n" + - " var rs_obj = false;\n" + - " var rs_callback = false;\n" + - " \n" + - " function rs_debug(text) {\n" + - " if (rs_debug_mode)\n" + - " alert('RSD: ' + text)\n" + - " }\n" + - " \n" + - " function rs_init_object() {\n" + - " rs_debug('rs_init_object() called..')\n" + - " \n" + - " var A;\n" + - " try {\n" + - " A=new ActiveXObject('Msxml2.XMLHTTP');\n" + - " } catch (e) {\n" + - " try {\n" + - " A=new ActiveXObject('Microsoft.XMLHTTP');\n" + - " } catch (oc) {\n" + - " A=null;\n" + - " }\n" + - " }\n" + - " if(!A && typeof XMLHttpRequest != 'undefined')\n" + - " A = new XMLHttpRequest();\n" + - " if (!A)\n" + - " rs_debug('Could not create connection object.');\n" + - " return A;\n" + - " }\n" - - Response.write(js_string_out) - } - - this.rs_esc=function(val) - { - - } - - this.export_function = function() - { - for(var i=0;i-1)) - { - uri += "?rs=" + escape(func_name) - } - else - { - uri += "&rs=" + escape(func_name) - } - - escapeduri = this.rs_esc(uri) - js_string_out = " // wrapper for "+func_name+"\n" + - " function x_"+func_name+"(){\n" + - " // count args; build URL\n" + - " var i, x, n;\n" + - " //var url = 'http://"+escapeduri+"', a = x_"+func_name+".arguments;\n" + - " url = 'http://"+escapeduri+"', a = x_"+func_name+".arguments;\n" + - " for (i = 0; i < a.length-1; i++)\n" + - " url = url + '&rsargs[]=' + escape(a[i]);\n" + - " x = rs_init_object();\n" + - " x.open('GET', url, true);\n" + - " x.onreadystatechange = function() {\n" + - " if (x.readyState != 4)\n" + - " return;\n" + - " rs_debug('received ' + x.responseText);\n" + - " \n" + - " var status;\n" + - " var data;\n" + - " status = x.responseText.charAt(0);\n" + - " data = x.responseText;\n" + - " var pos = data.indexOf('[sajax_result________end]]');\n " + - " if (status == '-'){\n" + - " if("+this.debug_mode+"){alert('Error: ' + data.substring(1,pos));}}\n" + - " else \n" + - " a[a.length-1](data.substring(1,pos));\n" + - " }\n" + - " x.send(null);\n" + - " rs_debug('x_"+func_name+" url = ' + url);\n" + - " rs_debug('x_"+func_name+" waiting..');\n" + - " }\n" - - Response.write(js_string_out) - } - } -%> \ No newline at end of file diff -uNr sajax-0.10/php/DEADJOE sajax-0.12/php/DEADJOE --- sajax-0.10/php/DEADJOE Wed Dec 31 19:00:00 1969 +++ sajax-0.12/php/DEADJOE Mon May 16 10:22:01 2005 @@ -0,0 +1,3 @@ + +*** Modified files in JOE when it aborted on Mon May 16 10:22:01 2005 +*** JOE was aborted by signal 15 diff -uNr sajax-0.10/php/Sajax.php sajax-0.12/php/Sajax.php --- sajax-0.10/php/Sajax.php Mon Mar 21 18:29:43 2005 +++ sajax-0.12/php/Sajax.php Mon Jan 30 02:56:28 2006 @@ -5,25 +5,75 @@ * GLOBALS AND DEFAULTS * */ - $sajax_debug_mode = 0; - $sajax_export_list = array(); - $sajax_request_type = "GET"; - $sajax_remote_uri = ""; + $GLOBALS['sajax_version'] = '0.12'; + $GLOBALS['sajax_debug_mode'] = 0; + $GLOBALS['sajax_export_list'] = array(); + $GLOBALS['sajax_request_type'] = 'GET'; + $GLOBALS['sajax_remote_uri'] = ''; + $GLOBALS['sajax_failure_redirect'] = ''; /* * CODE * */ + + // + // Initialize the Sajax library. + // function sajax_init() { } + // + // Helper function to return the script's own URI. + // function sajax_get_my_uri() { - global $REQUEST_URI; - - return $REQUEST_URI; + return $_SERVER["REQUEST_URI"]; } - $sajax_remote_uri = sajax_get_my_uri(); + + // + // Helper function to return an eval()-usable representation + // of an object in JavaScript. + // + function sajax_get_js_repr($value) { + $type = gettype($value); + + if ($type == "boolean") { + return ($value) ? "Boolean(true)" : "Boolean(false)"; + } + elseif ($type == "integer") { + return "parseInt($value)"; + } + elseif ($type == "double") { + return "parseFloat($value)"; + } + elseif ($type == "array" || $type == "object" ) { + // + // XXX Arrays with non-numeric indices are not + // permitted according to ECMAScript, yet everyone + // uses them.. We'll use an object. + // + $s = "{ "; + if ($type == "object") { + $value = get_object_vars($value); + } + foreach ($value as $k=>$v) { + $esc_key = sajax_esc($k); + if (is_numeric($k)) + $s .= "$k: " . sajax_get_js_repr($v) . ", "; + else + $s .= "\"$esc_key\": " . sajax_get_js_repr($v) . ", "; + } + if (count($value)) + $s = substr($s, 0, -2); + return $s . " }"; + } + else { + $esc_val = sajax_esc($value); + $s = "'$esc_val'"; + return $s; + } + } function sajax_handle_client_request() { global $sajax_export_list; @@ -39,6 +89,8 @@ if (empty($mode)) return; + $target = ""; + if ($mode == "get") { // Bust cache in the head header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past @@ -65,7 +117,7 @@ else { echo "+:"; $result = call_user_func_array($func_name, $args); - echo $result; + echo "var res = " . trim(sajax_get_js_repr($result)) . "; res;"; } exit; } @@ -74,9 +126,10 @@ global $sajax_debug_mode; global $sajax_request_type; global $sajax_remote_uri; + global $sajax_failure_redirect; $t = strtoupper($sajax_request_type); - if ($t != "GET" && $t != "POST") + if ($t != "" && $t != "GET" && $t != "POST") return "// Invalid type: $t.. \n\n"; ob_start(); @@ -86,75 +139,148 @@ // (c) copyright 2005 modernmethod, inc var sajax_debug_mode = ; var sajax_request_type = ""; + var sajax_target_id = ""; + var sajax_failure_redirect = ""; function sajax_debug(text) { if (sajax_debug_mode) - alert("RSD: " + text) + alert(text); } + function sajax_init_object() { sajax_debug("sajax_init_object() called..") var A; - try { - A=new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { + + var msxmlhttp = new Array( + 'Msxml2.XMLHTTP.5.0', + 'Msxml2.XMLHTTP.4.0', + 'Msxml2.XMLHTTP.3.0', + 'Msxml2.XMLHTTP', + 'Microsoft.XMLHTTP'); + for (var i = 0; i < msxmlhttp.length; i++) { try { - A=new ActiveXObject("Microsoft.XMLHTTP"); - } catch (oc) { - A=null; + A = new ActiveXObject(msxmlhttp[i]); + } catch (e) { + A = null; } } + if(!A && typeof XMLHttpRequest != "undefined") A = new XMLHttpRequest(); if (!A) sajax_debug("Could not create connection object."); return A; } + + var sajax_requests = new Array(); + + function sajax_cancel() { + for (var i = 0; i < sajax_requests.length; i++) + sajax_requests[i].abort(); + } + function sajax_do_call(func_name, args) { var i, x, n; var uri; var post_data; + var target_id; + + sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id); + target_id = sajax_target_id; + if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "") + sajax_request_type = "GET"; uri = ""; if (sajax_request_type == "GET") { + if (uri.indexOf("?") == -1) - uri = uri + "?rs=" + escape(func_name); + uri += "?rs=" + escape(func_name); else - uri = uri + "&rs=" + escape(func_name); + uri += "&rs=" + escape(func_name); + uri += "&rst=" + escape(sajax_target_id); + uri += "&rsrnd=" + new Date().getTime(); + for (i = 0; i < args.length-1; i++) - uri = uri + "&rsargs[]=" + escape(args[i]); - uri = uri + "&rsrnd=" + new Date().getTime(); + uri += "&rsargs[]=" + escape(args[i]); + post_data = null; - } else { + } + else if (sajax_request_type == "POST") { post_data = "rs=" + escape(func_name); + post_data += "&rst=" + escape(sajax_target_id); + post_data += "&rsrnd=" + new Date().getTime(); + for (i = 0; i < args.length-1; i++) post_data = post_data + "&rsargs[]=" + escape(args[i]); } + else { + alert("Illegal request type: " + sajax_request_type); + } x = sajax_init_object(); - x.open(sajax_request_type, uri, true); - if (sajax_request_type == "POST") { - x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); - x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - } - x.onreadystatechange = function() { - if (x.readyState != 4) - return; - sajax_debug("received " + x.responseText); + if (x == null) { + if (sajax_failure_redirect != "") { + location.href = sajax_failure_redirect; + return false; + } else { + sajax_debug("NULL sajax object for user agent:\n" + navigator.userAgent); + return false; + } + } else { + x.open(sajax_request_type, uri, true); + // window.open(uri); + + sajax_requests[sajax_requests.length] = x; - var status; - var data; - status = x.responseText.charAt(0); - data = x.responseText.substring(2); - if (status == "-") - alert("Error: " + data); - else - args[args.length-1](data); + if (sajax_request_type == "POST") { + x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); + x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + } + + x.onreadystatechange = function() { + if (x.readyState != 4) + return; + + sajax_debug("received " + x.responseText); + + var status; + var data; + var txt = x.responseText.replace(/^\s*|\s*$/g,""); + status = txt.charAt(0); + data = txt.substring(2); + + if (status == "") { + // let's just assume this is a pre-response bailout and let it slide for now + } else if (status == "-") + alert("Error: " + data); + else { + if (target_id != "") + document.getElementById(target_id).innerHTML = eval(data); + else { + try { + var callback; + var extra_data = false; + if (typeof args[args.length-1] == "object") { + callback = args[args.length-1].callback; + extra_data = args[args.length-1].extra_data; + } else { + callback = args[args.length-1]; + } + callback(eval(data), extra_data); + } catch (e) { + sajax_debug("Caught error " + e + ": Could not eval " + data ); + } + } + } + } } - x.send(post_data); + sajax_debug(func_name + " uri = " + uri + "/post = " + post_data); + x.send(post_data); sajax_debug(func_name + " waiting.."); delete x; + return true; } $v) { + $esc_key = sajax_esc($k); + if (is_numeric($k)) + $s .= "$k: " . sajax_get_js_repr($v) . ", "; + else + $s .= "\"$esc_key\": " . sajax_get_js_repr($v) . ", "; + } + if (count($value)) + $s = substr($s, 0, -2); + return $s . " }"; + } + else { + $esc_val = sajax_esc($value); + $s = "'$esc_val'"; + return $s; + } + } function sajax_handle_client_request() { global $sajax_export_list; @@ -39,6 +89,8 @@ if (empty($mode)) return; + $target = ""; + if ($mode == "get") { // Bust cache in the head header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past @@ -65,7 +117,7 @@ else { echo "+:"; $result = call_user_func_array($func_name, $args); - echo $result; + echo "var res = " . trim(sajax_get_js_repr($result)) . "; res;"; } exit; } @@ -74,9 +126,10 @@ global $sajax_debug_mode; global $sajax_request_type; global $sajax_remote_uri; + global $sajax_failure_redirect; $t = strtoupper($sajax_request_type); - if ($t != "GET" && $t != "POST") + if ($t != "" && $t != "GET" && $t != "POST") return "// Invalid type: $t.. \n\n"; ob_start(); @@ -86,75 +139,148 @@ // (c) copyright 2005 modernmethod, inc var sajax_debug_mode = ; var sajax_request_type = ""; + var sajax_target_id = ""; + var sajax_failure_redirect = ""; function sajax_debug(text) { if (sajax_debug_mode) - alert("RSD: " + text) + alert(text); } + function sajax_init_object() { sajax_debug("sajax_init_object() called..") var A; - try { - A=new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { + + var msxmlhttp = new Array( + 'Msxml2.XMLHTTP.5.0', + 'Msxml2.XMLHTTP.4.0', + 'Msxml2.XMLHTTP.3.0', + 'Msxml2.XMLHTTP', + 'Microsoft.XMLHTTP'); + for (var i = 0; i < msxmlhttp.length; i++) { try { - A=new ActiveXObject("Microsoft.XMLHTTP"); - } catch (oc) { - A=null; + A = new ActiveXObject(msxmlhttp[i]); + } catch (e) { + A = null; } } + if(!A && typeof XMLHttpRequest != "undefined") A = new XMLHttpRequest(); if (!A) sajax_debug("Could not create connection object."); return A; } + + var sajax_requests = new Array(); + + function sajax_cancel() { + for (var i = 0; i < sajax_requests.length; i++) + sajax_requests[i].abort(); + } + function sajax_do_call(func_name, args) { var i, x, n; var uri; var post_data; + var target_id; + + sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id); + target_id = sajax_target_id; + if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "") + sajax_request_type = "GET"; uri = ""; if (sajax_request_type == "GET") { + if (uri.indexOf("?") == -1) - uri = uri + "?rs=" + escape(func_name); + uri += "?rs=" + escape(func_name); else - uri = uri + "&rs=" + escape(func_name); + uri += "&rs=" + escape(func_name); + uri += "&rst=" + escape(sajax_target_id); + uri += "&rsrnd=" + new Date().getTime(); + for (i = 0; i < args.length-1; i++) - uri = uri + "&rsargs[]=" + escape(args[i]); - uri = uri + "&rsrnd=" + new Date().getTime(); + uri += "&rsargs[]=" + escape(args[i]); + post_data = null; - } else { + } + else if (sajax_request_type == "POST") { post_data = "rs=" + escape(func_name); + post_data += "&rst=" + escape(sajax_target_id); + post_data += "&rsrnd=" + new Date().getTime(); + for (i = 0; i < args.length-1; i++) post_data = post_data + "&rsargs[]=" + escape(args[i]); } + else { + alert("Illegal request type: " + sajax_request_type); + } x = sajax_init_object(); - x.open(sajax_request_type, uri, true); - if (sajax_request_type == "POST") { - x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); - x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - } - x.onreadystatechange = function() { - if (x.readyState != 4) - return; - sajax_debug("received " + x.responseText); + if (x == null) { + if (sajax_failure_redirect != "") { + location.href = sajax_failure_redirect; + return false; + } else { + sajax_debug("NULL sajax object for user agent:\n" + navigator.userAgent); + return false; + } + } else { + x.open(sajax_request_type, uri, true); + // window.open(uri); + + sajax_requests[sajax_requests.length] = x; - var status; - var data; - status = x.responseText.charAt(0); - data = x.responseText.substring(2); - if (status == "-") - alert("Error: " + data); - else - args[args.length-1](data); + if (sajax_request_type == "POST") { + x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); + x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + } + + x.onreadystatechange = function() { + if (x.readyState != 4) + return; + + sajax_debug("received " + x.responseText); + + var status; + var data; + var txt = x.responseText.replace(/^\s*|\s*$/g,""); + status = txt.charAt(0); + data = txt.substring(2); + + if (status == "") { + // let's just assume this is a pre-response bailout and let it slide for now + } else if (status == "-") + alert("Error: " + data); + else { + if (target_id != "") + document.getElementById(target_id).innerHTML = eval(data); + else { + try { + var callback; + var extra_data = false; + if (typeof args[args.length-1] == "object") { + callback = args[args.length-1].callback; + extra_data = args[args.length-1].extra_data; + } else { + callback = args[args.length-1]; + } + callback(eval(data), extra_data); + } catch (e) { + sajax_debug("Caught error " + e + ": Could not eval " + data ); + } + } + } + } } - x.send(post_data); + sajax_debug(func_name + " uri = " + uri + "/post = " + post_data); + x.send(post_data); sajax_debug(func_name + " waiting.."); delete x; + return true; } +// 2- loading the server's date from the php function, +// calling the javascript function to show it. +// 3- scheduling another load to the next second +// +// Disclaimer: Hey! I dont speak english +// Under (put your choice here) license + +function show_now() { + //return server date + return date("l dS of F Y h:i:s A"); +} + +//starting SAJAX stuff +$sajax_request_type = "GET"; +sajax_init(); +sajax_export("show_now"); +sajax_handle_client_request(); +?> + + + Show Server's Date + + + + +Server date:
(loading...)
+ + diff -uNr sajax-0.10/php/example_options.php sajax-0.12/php/example_options.php --- sajax-0.10/php/example_options.php Wed Dec 31 19:00:00 1969 +++ sajax-0.12/php/example_options.php Tue Apr 12 14:24:19 2005 @@ -0,0 +1,55 @@ +$v) { + $s .= "$k:$v\n"; + } + return $s; + } + + function test_post() { + $s = "-- POST --\n"; + foreach ($_POST as $k=>$v) { + $s .= "$k:$v\n"; + } + return $s; + } + + function get_the_time() { + return date("Y-m-d h:i:s"); + } + + // $sajax_debug_mode = 1; + sajax_init(); + sajax_export("test_get", "test_post", "get_the_time"); + sajax_handle_client_request(); + +?> + + +Example of Sajax Options + + + + + + + + + + +
+Time will appear here +
+ + + diff -uNr sajax-0.10/php/example_types.php sajax-0.12/php/example_types.php --- sajax-0.10/php/example_types.php Wed Dec 31 19:00:00 1969 +++ sajax-0.12/php/example_types.php Tue Apr 12 13:14:14 2005 @@ -0,0 +1,71 @@ + "Tom", "age" => 26); + } + + function return_object() { + class MyObj { + var $name, $age; + + function MyObj($name, $age) { + $this->name = $name; + $this->age = $age; + } + } + $o = new MyObj("Tom", 26); + return $o; + } + + function return_string() { + return "Name: Tom / Age: 26"; + } + + function return_int() { + return 26; + } + + function return_float() { + return 26.25; + } + + $sajax_request_type = "GET"; + sajax_init(); + sajax_export("return_array", "return_object", "return_string", + "return_int", "return_float"); + sajax_handle_client_request(); +?> + + + + + + + + + + + + diff -uNr sajax-0.10/php/example_wall.php sajax-0.12/php/example_wall.php --- sajax-0.10/php/example_wall.php Tue Apr 12 16:30:28 2005 +++ sajax-0.12/php/example_wall.php Mon Jan 30 02:56:59 2006 @@ -1,12 +1,8 @@ - @@ -54,11 +49,17 @@ ?> var check_n = 0; + var old_data = "--"; - function refresh_cb(new_data) { - document.getElementById("wall").innerHTML = new_data; + function refresh_cb(new_data) { + if (new_data != old_data) { + document.getElementById("wall").innerHTML = new_data; + setTimeout("refresh()", 1000); + old_data = new_data; + } else { + setTimeout("refresh()", 2500); + } document.getElementById("status").innerHTML = "Checked #" + check_n++; - setTimeout("refresh()", 1000); } function refresh() { @@ -77,6 +78,7 @@ line = document.getElementById("line").value; if (line == "") return; + sajax_request_type = "POST"; x_add_line("[" + handle + "] " + line, add_cb); document.getElementById("line").value = ""; } @@ -86,8 +88,11 @@
- Sajax - - + Sajax + v + - + You are a guinea pig + - This example illustrates the simplest possible graffiti wall. It isn't meant to be perfect, featureful, or even useful.
diff -uNr sajax-0.10/php/example_wall.php.txt sajax-0.12/php/example_wall.php.txt --- sajax-0.10/php/example_wall.php.txt Tue Apr 12 16:30:28 2005 +++ sajax-0.12/php/example_wall.php.txt Mon Jan 30 02:56:59 2006 @@ -1,12 +1,8 @@ - @@ -54,11 +49,17 @@ ?> var check_n = 0; + var old_data = "--"; - function refresh_cb(new_data) { - document.getElementById("wall").innerHTML = new_data; + function refresh_cb(new_data) { + if (new_data != old_data) { + document.getElementById("wall").innerHTML = new_data; + setTimeout("refresh()", 1000); + old_data = new_data; + } else { + setTimeout("refresh()", 2500); + } document.getElementById("status").innerHTML = "Checked #" + check_n++; - setTimeout("refresh()", 1000); } function refresh() { @@ -77,6 +78,7 @@ line = document.getElementById("line").value; if (line == "") return; + sajax_request_type = "POST"; x_add_line("[" + handle + "] " + line, add_cb); document.getElementById("line").value = ""; } @@ -86,8 +88,11 @@ - Sajax - - + Sajax + v + - + You are a guinea pig + - This example illustrates the simplest possible graffiti wall. It isn't meant to be perfect, featureful, or even useful.