r9327: Rename parent to fParent to prevent confusion with window.parent object.
[jra/samba/.git] / swat / esptest / registry.esp
1 <%
2 /******************************/
3 /* server side AJAJ functions */
4 libinclude("base.js");
5 libinclude("winreg.js");
6 libinclude("server_call.js");
7
8 /* 
9    server side call to return a listing of elements in a winreg path
10 */
11 function enum_path(binding, path) {
12         printf("enum_path(%s, %s)\n", binding, path);
13         var reg = winreg_init();
14         security_init(reg);
15
16         reg.credentials = session.authinfo.credentials;
17
18         var status = reg.connect(binding);
19         if (status.is_ok != true) {
20                 printVars(status);
21                 return undefined;
22         }
23         var list = winreg_enum_path(reg, path);
24         return list;
25 }
26
27 /* register a call for clients to make */
28 var call = servCallObj();
29 call.add('enum_path', enum_path);
30
31 /* run the function that was asked for */
32 call.run();
33
34   /***********************/
35   /* now the main page */
36   page_header("columns", "ESP registry edit", "esptest"); 
37 %>
38
39 <script type="text/javascript" src="/scripting/client/encoder.js"></script>
40 <script type="text/javascript" src="/scripting/client/call.js"></script>
41
42 <h1>Registry Editor</h1>
43
44   <script type="text/javascript">
45
46 function folder_list(fParent, list) {
47         var i;
48         fParent.populated = true;
49         fParent.removeAll();
50         for (i=0;i<list.length;i++) {
51                 var fChild;
52                 fChild = new QxTreeFolder(list[i]);
53                 fParent.add(fChild);
54                 fChild.binding = fParent.binding;
55                 if (fParent.reg_path == '\\\\') {
56                         fChild.reg_path = list[i];
57                 } else {
58                         fChild.reg_path = fParent.reg_path + '\\\\' + list[i];
59                 }
60                 fChild.add(new QxTreeFolder('Working ...'));
61                 fChild.addEventListener("click", function() { 
62                         var el = this; folder_click(el); 
63                 });
64                 fParent.setOpen(1);
65         }
66 }
67
68 function folder_click(node) {
69         if (!node.populated) {
70                 server_call_url("@@request.REQUEST_URI", 'enum_path', 
71                             function(list) { folder_list(node, list); }, 
72                             node.binding, node.reg_path);
73         }
74 }
75
76 /* return a registry tree for the given server */
77 function registry_tree(binding) {
78       var tree = new QxTree("registry: " + binding);
79       tree.binding = binding;
80       tree.reg_path = "\\\\";
81       tree.populated = false;
82       with(tree)
83       {
84         setBackgroundColor(255);
85         setBorder(QxBorder.presets.inset);
86         setOverflow("scroll");
87         setStyleProperty("padding", "2px");
88         setWidth(400);
89         setHeight(400);
90         setTop(20);
91       }
92       tree.addEventListener("click", function() { 
93               var el = this; folder_click(el); 
94       });
95       return tree;
96 }
97
98   window.application.main = function()
99   {
100     var inlineWidget = new QxInline;
101     var fieldSet = new QxFieldSet("Registry");
102     var binding = "ncalrpc:";
103
104     with(fieldSet)
105     {
106             setWidth("40%");
107             setMinHeight(500);
108             setBottom(48);
109             setMinWidth(500);
110     };
111
112     var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%");
113     gl.setEdge(0);
114     gl.setCellPaddingTop(3);
115     gl.setCellPaddingBottom(3);
116
117     inlineWidget.add(fieldSet);
118
119     var t = registry_tree(binding);
120
121     function change_binding(e) {
122             binding = e.getNewValue();
123             srv_printf("changed binding to %s\\n", binding);
124             gl.remove(t);
125             t = registry_tree(binding);
126             gl.add(t, { row : 2, col : 1 });
127     }
128
129     var b = new QxTextField(binding);
130     b.addEventListener("changeText", change_binding);
131
132     gl.add(b, { row : 1, col : 1 });
133     gl.add(t, { row : 2, col : 1 });
134
135     fieldSet.add(gl);
136     inlineWidget.add(fieldSet);
137     this.getClientWindow().getDocument().add(inlineWidget, "canvas");
138   };
139
140   </script>
141
142
143  <div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div>
144
145 <% page_footer(); %>