2 client side js functions for remote calls into the server
4 Copyright Andrew Tridgell 2005
5 released under the GNU GPL Version 2 or later
8 var __call = new Object();
11 we can't use the qooxdoo portability layer for this, as it assumes
12 you are using an XML transport, so instead replicate the portability
13 code for remote calls here. Don't look too closely or you will go
16 __call._activex = window.ActiveXObject && !(new QxClient).isOpera() ? true : false;
17 __call._activexobj = null;
18 __call._ok = QxXmlHttpLoader._http || QxXmlHttpLoader._activex;
20 if (__call._activex) {
21 var servers = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
22 for (var i=0; i<servers.length; i++) {
24 var o = new ActiveXObject(servers[i] + ".XMLHTTP");
25 __call._activexobj = servers[i];
32 return a http object ready for a remote call
34 function __http_object() {
35 return __call._activex ?
36 new ActiveXObject(__call._activexobj + ".XMLHTTP") :
43 vserver_call(url, func, callback, args);
45 'func' is a function name to call on the server
46 any additional arguments are passed to func() on the server
48 The callback() function is called with the returned
49 object. 'callback' may be null.
51 function vserver_call(url, func, callback, args) {
52 var args2 = new Object();
53 args2.length = args.length;
55 for (i=0;i<args.length;i++) {
58 var req = __http_object();
59 req.open("POST", url, true);
60 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
61 req.send("func=" + func + "&args=" + encodeObject(args2));
62 req.onreadystatechange = function() {
63 if (4 == req.readyState && callback != null) {
64 var o = decodeObject(req.responseText);
74 server_call(url, func, callback, ...);
76 'func' is a function name to call on the server
77 any additional arguments are passed to func() on the server
79 The callback() function is called with the returned
80 object. 'callback' may be null.
82 function server_call(url, func, callback) {
83 var args = new Object();
85 for (i=3;i<arguments.length;i++) {
86 args[i-3] = arguments[i];
89 vserver_call(url, func, callback, args);
94 call printf on the server
96 function srv_printf() {
97 vserver_call('/scripting/general_calls.esp', 'srv_printf', null, arguments);