Module "w2t"
============

The SPL Web 2.0 Toolkit

This module is EXPERIMENTAL and not so well document yet.
Expect more to come..
 
var w2t_core_scripts = <>;
--------------------------

The core w2t browser-side scripts.

This JavaScript code block defines the following functions:

	function w2t_encode_xml(text)

		XML-encode the parameter and return the encoded text

	function w2t_console_open()

		Open a W2T console window (for debug purposes).
		Usually one adds a little button or link to the development
		versions of an application which calls this function.

	function w2t_console(title, text)

		This function can be used to write a message to all open
		W2T console windows.

	function w2t_proccess_dom(n)
	function w2t_proccess(xmldata)
	function w2t_update_status()
	function w2t_gc()

		Some functions used internally by w2t_send() for creating the
		XML requests and processing the XML responses.

	function w2t_send(xmldata, onfinish)

		Send a request specified in 'xmldata' to the server and call
		'onfinish' after the response has been processed. Usually
		one is calling w2t_callback() instead of using w2t_send()
		directly.

	function w2t_callback(callback_name, arguments)

		Call a callback on the server.
		The second argument is an array of arguments.

	function w2t_animate(finish, workers, seconds, fps)

		A generic helper function for animations. The animation runs
		for the specified number of seconds with the specified number
		of frames per second. Frames are automatically skipped when
		rendering becomes too slow. For each frame all functions in
		the 'workers' array are called with a floating point value
		as parameter (0 for the first frame up to 1 for the last one).

	function w2t_animate_fade(id, attr, newval)
	function w2t_animate_svgmove(id, newx, newy)

		Helper functions which do return function pointers to
		dynamically created worker functions for w2t_animate().

 

object W2t
----------

The W2t object.
 

static W2t.scripts = [ w2t_core_scripts ];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

An array with JavaScript fragments. Other modules can push their
own script fragments to this array when loaded. This scripts are
then automatically included in the application startup page.
	 

static W2t.styles = [ ];
~~~~~~~~~~~~~~~~~~~~~~~~

An array with CSS stylesheet fragments. Other modules can push
their own css fragments to this array when loaded. This scripts
are then automatically included in the application startup page.
	 

static W2t.w2t_ns = "http://www.spl-scripting.org/xml/w2t";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The namespace URI for the "w2t" namespace prefix.
	 

static W2t.xmlns;
~~~~~~~~~~~~~~~~~

A hash of namespace declarations one usually wants to use for Web
2.0 applications (prefix as key and URI as value). Other modules
(and w2t applications) may add additional namespaces. Per default
the following namespaces are defined:

	w2t     w2t_ns
	svg     http://www.w3.org/2000/svg
	xhtml   http://www.w3.org/1999/xhtml
	xlink   http://www.w3.org/1999/xlink

This hash is used by getxmlnsdecls().
	 

var W2t.startup;
~~~~~~~~~~~~~~~~

The startup page content. This variable must be set before calling
run().
	 

var W2t.mime_type = "text/xml";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The mime type of the startup page.
	 

var W2t.callbacks;
~~~~~~~~~~~~~~~~~~

A hash with all callbacks.

Use register_callback() to add entries.
	 

var W2t.callbacks_oncleanup;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A hash with oncleanup event handlers for the callbacks. When the
callback garbage collector cleans up a callback, it also executes
the oncleanup handler if there is one.

Use register_callback() to add entries.
	 

var W2t.callbacks_rev = 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~

A revision counter for the callbacks list. It is automatically
incremented by register_callback(). This counter is needed
to work arround possible race conditions in the client-side
garbage collection algorithm.
	 

var W2t.request;
~~~~~~~~~~~~~~~~

The current request (when run() is active). This is an XML
document handler.
	 

var W2t.response;
~~~~~~~~~~~~~~~~~

The current response (when run() is active). This is an XML
document handler.
	 

method W2t.register_callback(id, handler, oncleanup);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Register a new callback.
	 

method W2t.response_add(xmltext);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Add a new XML snippet to the response document.
	 

method W2t.dom_appendchild(id, xmltext);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Append a child node in the client DOM tree.
	 

method W2t.dom_remove(id);
~~~~~~~~~~~~~~~~~~~~~~~~~~

Remove a node from the client DOM tree.
	 

method W2t.dom_replaceinner(id, xmltext);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Replace the inner XML text of node in the client DOM tree.
	 

method W2t.dom_setattr(id, name, value);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Set (and create if needed) an attribute.
	 

method W2t.execute(script);
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Execute the javascript fragment passed as argument in the client.
	 

method W2t.getscripts();
~~~~~~~~~~~~~~~~~~~~~~~~

Return the concatenated contents of scripts with an additional
header. This must be included in a <script><![CDATA[ .. ]]></script>
block within the startup document.
	 

method W2t.getstyles();
~~~~~~~~~~~~~~~~~~~~~~~

Return the concatenated contents of styles. This must be
included in a <style type="text/css"><![CDATA[ .. ]]></style>
block within the startup document.
	 

method W2t.getxmlnsdecls();
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return a string with 'xmlns:PREFIX="URI"' xml namespace declarations
built using the xmlns hash described above.
	 

method W2t.getid();
~~~~~~~~~~~~~~~~~~~

Get a unique id, e.g. for the id="" attribute of auto-generated
XML elements and for callback names.
	 

method W2t.run();
~~~~~~~~~~~~~~~~~

Main runloop. This function never returns. It just calls prior
registered callback functions.
	 

method W2t.init();
~~~~~~~~~~~~~~~~~~

Constructor.
	 
