diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-08-20 22:45:48 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:34:14 -0500 |
commit | 2997f4bd43420163ee01fcbacdf8cf958dedcfea (patch) | |
tree | 92ed5c08973bd6ee18eb5454b4c89df17bdcb7a0 /swat | |
parent | 449c6acd70221ca257eeb4b82de428760e089d59 (diff) | |
download | samba-2997f4bd43420163ee01fcbacdf8cf958dedcfea.tar.gz samba-2997f4bd43420163ee01fcbacdf8cf958dedcfea.tar.bz2 samba-2997f4bd43420163ee01fcbacdf8cf958dedcfea.zip |
r9434: moved the registry editor into a common js library. Deryck, does this
look ok? Apologies if this treads on your toes.
(This used to be commit 8295eb01c0e1eec4f7c5bd211eac80b92ff9549e)
Diffstat (limited to 'swat')
-rw-r--r-- | swat/desktop/index.esp | 127 | ||||
-rw-r--r-- | swat/esptest/registry.esp | 154 | ||||
-rw-r--r-- | swat/scripting/client/regedit.js | 118 | ||||
-rw-r--r-- | swat/scripting/server/regedit.esp | 35 |
4 files changed, 181 insertions, 253 deletions
diff --git a/swat/desktop/index.esp b/swat/desktop/index.esp index 8fe45ed4a0..a81581bf3c 100644 --- a/swat/desktop/index.esp +++ b/swat/desktop/index.esp @@ -1,96 +1,15 @@ <% /*** Reg stuff ***/ 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(); -/** endReg stuff *****/ - page_header("desktop", "Virtual Desktop Design Test", "desktop"); %> <script type="text/javascript" src="/scripting/client/encoder.js"></script> <script type="text/javascript" src="/scripting/client/call.js"></script> +<script type="text/javascript" src="/scripting/client/regedit.js"></script> <script type="text/javascript"> -function folder_list(fParent, list) { - var i; - fParent.populated = true; - fParent.removeAll(); - for (i=0;i<list.length;i++) { - var fChild; - fChild = new QxTreeFolder(list[i]); - fParent.add(fChild); - fChild.binding = fParent.binding; - if (fParent.reg_path == '\\\\') { - fChild.reg_path = list[i]; - } else { - fChild.reg_path = fParent.reg_path + '\\\\' + list[i]; - } - fChild.add(new QxTreeFolder('Working ...')); - fChild.addEventListener("click", function() { - var el = this; folder_click(el); - }); - fParent.setOpen(1); - } -} - -function folder_click(node) { - if (!node.populated) { - server_call_url("@@request.REQUEST_URI", 'enum_path', - function(list) { folder_list(node, list); }, - node.binding, node.reg_path); - } -} - -/* return a registry tree for the given server */ -function registry_tree(binding) { - var tree = new QxTree("registry: " + binding); - tree.binding = binding; - tree.reg_path = "\\\\"; - tree.populated = false; - with(tree) - { - setBackgroundColor(255); - setBorder(QxBorder.presets.inset); - setOverflow("scroll"); - setStyleProperty("padding", "2px"); - setWidth(400); - setHeight(400); - setTop(20); - } - tree.addEventListener("click", function() { - var el = this; folder_click(el); - }); - return tree; -} - /*** init the page for qooxdoo ***/ window.application.main = function() { @@ -100,47 +19,9 @@ window.application.main = function() function showReg() { - var inlineWidget = new QxInline; - var fieldSet = new QxFieldSet("Registry"); - var binding = "ncalrpc:"; - - with(fieldSet) - { - setWidth("40%"); - setMinHeight(500); - setBottom(48); - setMinWidth(500); - setBackgroundColor("#FFF"); - }; - - var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%"); - gl.setEdge(0); - gl.setCellPaddingTop(3); - gl.setCellPaddingBottom(3); - - inlineWidget.add(fieldSet); - - var t = registry_tree(binding); - - function change_binding(e) { - binding = e.getNewValue(); - srv_printf("changed binding to %s\\n", binding); - gl.remove(t); - t = registry_tree(binding); - gl.add(t, { row : 2, col : 1 }); - } - - var b = new QxTextField(binding); - b.addEventListener("changeText", change_binding); - - gl.add(b, { row : 1, col : 1 }); - gl.add(t, { row : 2, col : 1 }); - - fieldSet.add(gl); - inlineWidget.add(fieldSet); - doc.add(inlineWidget, "canvas"); - - w1.setVisible(false); + var regedit = regedit_widget("ncalrpc:"); + doc.add(regedit); + regedit.startup(); } function startSwat() diff --git a/swat/esptest/registry.esp b/swat/esptest/registry.esp index 14e3173f2d..b65b5d1b24 100644 --- a/swat/esptest/registry.esp +++ b/swat/esptest/registry.esp @@ -1,145 +1,39 @@ <% -/******************************/ -/* 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"); %> <script type="text/javascript" src="/scripting/client/encoder.js"></script> <script type="text/javascript" src="/scripting/client/call.js"></script> +<script type="text/javascript" src="/scripting/client/regedit.js"></script> <h1>Registry Editor</h1> - <script type="text/javascript"> - -function folder_list(fParent, list) { - var i; - fParent.populated = true; - fParent.removeAll(); - for (i=0;i<list.length;i++) { - var fChild; - fChild = new QxTreeFolder(list[i]); - fParent.add(fChild); - fChild.binding = fParent.binding; - if (fParent.reg_path == '\\\\') { - fChild.reg_path = list[i]; - } else { - fChild.reg_path = fParent.reg_path + '\\\\' + list[i]; - } - fChild.add(new QxTreeFolder('Working ...')); - fChild.addEventListener("click", function() { - var el = this; folder_click(el); - }); - fParent.setOpen(1); - } -} - -function folder_click(node) { - if (!node.populated) { - server_call_url("@@request.REQUEST_URI", 'enum_path', - function(list) { folder_list(node, list); }, - node.binding, node.reg_path); - } -} +<script type="text/javascript"> -/* return a registry tree for the given server */ -function registry_tree(binding) { - var tree = new QxTree("registry: " + binding); - tree.binding = binding; - tree.reg_path = "\\\\"; - tree.populated = false; - with(tree) - { - setBackgroundColor(255); - setBorder(QxBorder.presets.inset); - setOverflow("scroll"); - setStyleProperty("padding", "2px"); - setWidth(400); - setHeight(400); - setTop(20); - } - tree.addEventListener("click", function() { - var el = this; folder_click(el); - }); - return tree; -} - - window.application.main = function() - { +/*** init the page for qooxdoo ***/ +window.application.main = function() +{ + var doc = this.getClientWindow().getDocument(); var inlineWidget = new QxInline; - var fieldSet = new QxFieldSet("Registry"); - var binding = "ncalrpc:"; - - with(fieldSet) - { - setWidth("40%"); - setMinHeight(500); - setBottom(48); - setMinWidth(500); - }; - - var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%"); - gl.setEdge(0); - gl.setCellPaddingTop(3); - gl.setCellPaddingBottom(3); - - inlineWidget.add(fieldSet); - - var t = registry_tree(binding); - - function change_binding(e) { - binding = e.getNewValue(); - srv_printf("changed binding to %s\\n", binding); - gl.remove(t); - t = registry_tree(binding); - gl.add(t, { row : 2, col : 1 }); - } - - var b = new QxTextField(binding); - b.addEventListener("changeText", change_binding); - - gl.add(b, { row : 1, col : 1 }); - gl.add(t, { row : 2, col : 1 }); - - fieldSet.add(gl); - inlineWidget.add(fieldSet); - this.getClientWindow().getDocument().add(inlineWidget, "canvas"); - }; - - </script> + var qwidget = new QxWidget; + qwidget.setHeight(800); + qwidget.setWidth("100%"); + qwidget.setBorder(QxBorder.presets.groove); + + var btn1 = new QxButton("Registry Editor"); + btn1.set({ top: 20, left : 30 }); + btn1.addEventListener("click", function() { + var regedit = regedit_widget("ncalrpc:"); + qwidget.add(regedit); + regedit.startup(); + }); + qwidget.add(btn1); + inlineWidget.add(qwidget); + doc.add(inlineWidget, "canvas"); +} +</script> - <div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div> +<div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div> <% page_footer(); %> diff --git a/swat/scripting/client/regedit.js b/swat/scripting/client/regedit.js new file mode 100644 index 0000000000..5769a88785 --- /dev/null +++ b/swat/scripting/client/regedit.js @@ -0,0 +1,118 @@ +/* + client side js functions for registry editing + + Copyright Andrew Tridgell 2005 + released under the GNU GPL Version 2 or later +*/ + +function __folder_list(fParent, list) +{ + var i; + fParent.removeAll(); + for (i=0;i<list.length;i++) { + var fChild; + fChild = new QxTreeFolder(list[i]); + fParent.add(fChild); + fChild.binding = fParent.binding; + if (fParent.reg_path == '\\') { + fChild.reg_path = list[i]; + } else { + fChild.reg_path = fParent.reg_path + '\\' + list[i]; + } + fChild.add(new QxTreeFolder('Working ...')); + fChild.addEventListener("click", function() { + var el = this; __folder_click(el); + }); + fParent.setOpen(1); + } +} + +function __folder_click(node) +{ + if (!node.populated) { + node.populated = true; + server_call_url("/scripting/server/regedit.esp", 'enum_path', + function(list) { __folder_list(node, list); }, + node.binding, node.reg_path); + } +} + +/* return a registry tree for the given server */ +function __registry_tree(binding) +{ + var tree = new QxTree("registry: " + binding); + tree.binding = binding; + tree.reg_path = "\\"; + tree.populated = false; + with(tree) { + setBackgroundColor(255); + setBorder(QxBorder.presets.inset); + setOverflow("scroll"); + setStyleProperty("padding", "2px"); + setWidth("100%"); + setHeight("90%"); + setTop("10%"); + } + tree.addEventListener("click", function() { + var el = this; __folder_click(el); + }); + return tree; +} + +/* + create a registry editing widget and return it as a object + +*/ +function regedit_widget(binding) +{ + var regedit = new QxWindow("Registry Editor"); + regedit.setSpace(300, 600, 300, 600); + + var fieldSet = new QxFieldSet(); + + regedit.binding = binding; + + with(fieldSet) { + setWidth("100%"); + setHeight("100%"); + }; + + var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%"); + gl.setEdge(0); + gl.setCellPaddingTop(3); + gl.setCellPaddingBottom(3); + + regedit.add(fieldSet); + + var t = __registry_tree(regedit.binding); + + function change_binding(e) { + regedit.binding = e.getNewValue(); + srv_printf("changed binding to %s\\n", regedit.binding); + gl.remove(t); + t = __registry_tree(regedit.binding); + gl.add(t, { row : 2, col : 1 }); + } + + var b = new QxTextField(regedit.binding); + b.addEventListener("changeText", change_binding); + + gl.add(b, { row : 1, col : 1 }); + gl.add(t, { row : 2, col : 1 }); + + fieldSet.add(gl); + regedit.add(fieldSet); + + /* + call the startup() method to display the widget + */ + regedit.startup = function() { + this.setVisible(true); + this.setMoveable(true); + this.setResizeable(true); + this.setResizeMethod("frame"); + this.setMoveable(true); + } + + return regedit; +}; diff --git a/swat/scripting/server/regedit.esp b/swat/scripting/server/regedit.esp new file mode 100644 index 0000000000..31977d5a51 --- /dev/null +++ b/swat/scripting/server/regedit.esp @@ -0,0 +1,35 @@ +<% +/* + server side AJAJ functions for registry editing. These go along + with scripting/client/regedit.js +*/ +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(); +%> |