From 8942ac69f01acc2e09a56e6accef6034622d40d4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 Aug 2005 06:58:05 +0000 Subject: r9227: cleanup and simplify the AJAJ code (This used to be commit ceb7669e5991e9dda759d60a09a0a65e6caba991) --- swat/esptest/qooxdoo.esp | 28 ++++++++++++++++++++++++--- swat/esptest/registry.esp | 42 +++++++++++++++++++++++++++++++++++++--- swat/esptest/registry_calls.esp | 37 ----------------------------------- swat/esptest/remote.esp | 19 ------------------ swat/scripting/general_calls.esp | 1 - 5 files changed, 64 insertions(+), 63 deletions(-) delete mode 100644 swat/esptest/registry_calls.esp delete mode 100644 swat/esptest/remote.esp (limited to 'swat') diff --git a/swat/esptest/qooxdoo.esp b/swat/esptest/qooxdoo.esp index 76d3236fc9..554a4e90d5 100644 --- a/swat/esptest/qooxdoo.esp +++ b/swat/esptest/qooxdoo.esp @@ -1,4 +1,26 @@ -<% +<% +/******************************/ +/* server side AJAJ functions */ +libinclude("server_call.js"); + +/* this is a call that the client js code can make - it just adds + some more elements to the passed object, then returns the object */ +function testfunc(x) { + var sys = sys_init(); + x.nttime = sys.nttime(); + x.timestring = sys.httptime(x.nttime); + return x; +} + +/* register a call for clients to make */ +var call = servCallObj(); +call.add('testfunc', testfunc); + +/* run the function that was asked for */ +call.run(); + + /***********************/ + /* now the main page */ page_header("columns", "ESP qooxdoo test", "esptest"); %> @@ -48,7 +70,7 @@ shared.rate = shared.counter / (shared.time_diff * 0.0000001); shared.counter++; if (stopit == 0) { - server_call('remote.esp', 'testfunc', callback, shared); + server_call_url("@@request.REQUEST_URI", 'testfunc', callback, shared); } } @@ -57,7 +79,7 @@ stopit = 0; shared.counter = 0; shared.start_time = 0; - server_call('remote.esp', 'testfunc', callback, shared); + server_call_url("@@request.REQUEST_URI", 'testfunc', callback, shared); }; function stop_call() { diff --git a/swat/esptest/registry.esp b/swat/esptest/registry.esp index 2b6a214473..6adeb78b81 100644 --- a/swat/esptest/registry.esp +++ b/swat/esptest/registry.esp @@ -1,4 +1,38 @@ -<% +<% +/******************************/ +/* server side AJAJ functions */ +libinclude("base.js"); +libinclude("winreg.js"); +libinclude("server_call.js"); + +/* + server side call to return a listing of elements in a winreg path +*/ +function enum_path(binding, path) { + printf("enum_path(%s, %s)\n", binding, path); + var reg = winreg_init(); + security_init(reg); + + reg.credentials = session.authinfo.credentials; + + var status = reg.connect(binding); + if (status.is_ok != true) { + printVars(status); + return undefined; + } + var list = winreg_enum_path(reg, path); + return list; +} + +/* register a call for clients to make */ +var call = servCallObj(); +call.add('enum_path', enum_path); + +/* run the function that was asked for */ +call.run(); + + /***********************/ + /* now the main page */ page_header("columns", "ESP registry edit", "esptest"); %> @@ -33,7 +67,7 @@ function folder_list(t, list) { function folder_click(t) { if (!t.populated) { - server_call("registry_calls.esp", 'enum_path', + server_call_url("@@request.REQUEST_URI", 'enum_path', function(list) { folder_list(t, list); }, t.binding, t.reg_path); } @@ -54,8 +88,10 @@ function registry_tree(binding) { setWidth(400); setHeight(400); setTop(20); - addEventListener("click", function() { folder_click(t); }); } + t.addEventListener("click", function() { + var el = this; folder_click(el); + }); return t; } diff --git a/swat/esptest/registry_calls.esp b/swat/esptest/registry_calls.esp deleted file mode 100644 index a5c1ae7a12..0000000000 --- a/swat/esptest/registry_calls.esp +++ /dev/null @@ -1,37 +0,0 @@ -<% -libinclude("base.js"); -libinclude("winreg.js"); -libinclude("server_call.js"); - -/* - server side call to return a listing of elements in a winreg path -*/ -function enum_path(binding, path) { - printf("enum_path(%s, %s)\n", binding, path); - if (path == "\\") { - printf("IN ROOT\n"); - var list = new Array("HKLM", "HKCR", "HKPD"); - return list; - } - printf("binding=%s path=%s\n", binding, path); - var reg = winreg_init(); - security_init(reg); - - reg.credentials = session.authinfo.credentials; - - var status = reg.connect(binding); - if (status.is_ok != true) { - printVars(status); - return undefined; - } - var list = winreg_enum_path(reg, path); - return list; -} - -/* register a call for clients to make */ -var call = servCallObj(); -call.add('enum_path', enum_path); - -/* run the function that was asked for */ -call.run(); -%> diff --git a/swat/esptest/remote.esp b/swat/esptest/remote.esp deleted file mode 100644 index c0f12147a8..0000000000 --- a/swat/esptest/remote.esp +++ /dev/null @@ -1,19 +0,0 @@ -<% -libinclude("server_call.js"); - -/* this is a call that the client js code can make - it just adds - some more elements to the passed object, then returns the object */ -function testfunc(x) { - var sys = sys_init(); - x.nttime = sys.nttime(); - x.timestring = sys.httptime(x.nttime); - return x; -} - -/* register a call for clients to make */ -var call = servCallObj(); -call.add('testfunc', testfunc); - -/* run the function that was asked for */ -call.run(); -%> diff --git a/swat/scripting/general_calls.esp b/swat/scripting/general_calls.esp index 3a78ff6bbb..f17c43205a 100644 --- a/swat/scripting/general_calls.esp +++ b/swat/scripting/general_calls.esp @@ -12,7 +12,6 @@ var call = servCallObj(); */ function srv_printf() { - println("in srv_printf"); var s = string_init(); print(s.vsprintf(arguments)); return undefined; -- cgit