r9213: some improvements to the registry editor code
[ira/wip.git] / swat / esptest / registry.esp
1 <% 
2   page_header("columns", "ESP registry edit", "esptest"); 
3 %>
4
5 <script type="text/javascript" src="/scripting/client/encoder.js"></script>
6 <script type="text/javascript" src="/scripting/client/call.js"></script>
7
8 <h1>Registry Editor</h1>
9
10   <script type="text/javascript">
11
12 function folder_list(t, list) {
13         var i;
14         t.populated = true;
15         t.removeAll();
16         for (i=0;i<list.length;i++) {
17                 var te;
18                 te = new QxTreeFolder(list[i]);
19                 t.add(te);
20                 te.binding = t.binding;
21                 if (t.reg_path == '\\\\') {
22                         te.reg_path = list[i];
23                 } else {
24                         te.reg_path = t.reg_path + '\\\\' + list[i];
25                 }
26                 te.add(new QxTreeFolder('Working ...'));
27                 te.addEventListener("click", function() { 
28                         var el = this; folder_click(el); 
29                 });
30                 t.setOpen(1);
31         }
32 }
33
34 function folder_click(t) {
35         if (!t.populated) {
36                 server_call("registry_calls.esp", 'enum_path', 
37                             function(list) { folder_list(t, list); }, 
38                             t.binding, t.reg_path);
39         }
40 }
41
42 /* return a registry tree for the given server */
43 function registry_tree(binding) {
44       var t = new QxTree("registry: " + binding);
45       t.binding = binding;
46       t.reg_path = "\\\\";
47       t.populated = false;
48       with(t)
49       {
50         setBackgroundColor(255);
51         setBorder(QxBorder.presets.inset);
52         setOverflow("scroll");
53         setStyleProperty("padding", "2px");
54         setWidth(400);
55         setHeight(400);
56         setTop(20);
57         addEventListener("click", function() { folder_click(t); });
58       }
59       return t;
60 }
61
62   window.application.main = function()
63   {
64     var inlineWidget = new QxInline;
65     var fieldSet = new QxFieldSet("Registry");
66     var binding = "ncalrpc:";
67
68     with(fieldSet)
69     {
70             setWidth("40%");
71             setMinHeight(500);
72             setBottom(48);
73             setMinWidth(500);
74     };
75
76     var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%");
77     gl.setEdge(0);
78     gl.setCellPaddingTop(3);
79     gl.setCellPaddingBottom(3);
80
81     inlineWidget.add(fieldSet);
82
83     var t = registry_tree(binding);
84
85     function change_binding(e) {
86             binding = e.getNewValue();
87             srv_printf("changed binding to %s\\n", binding);
88             gl.remove(t);
89             t = registry_tree(binding);
90             gl.add(t, { row : 2, col : 1 });
91     }
92
93     var b = new QxTextField(binding);
94     b.addEventListener("changeText", change_binding);
95
96     gl.add(b, { row : 1, col : 1 });
97     gl.add(t, { row : 2, col : 1 });
98
99     fieldSet.add(gl);
100     inlineWidget.add(fieldSet);
101     this.getClientWindow().getDocument().add(inlineWidget, "canvas");
102   };
103
104   </script>
105
106
107  <div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div>
108
109 <% page_footer(); %>