r10228: Reorganizing a bit, trying to simplify. This is an attempt
[jelmer/samba4-debian.git] / swat / desktop / index.esp
1 <% 
2 libinclude("base.js");
3         page_header("desktop", "Virtual Desktop Design Test", "desktop");
4 %>
5
6 <script type="text/javascript" src="/scripting/client/encoder.js"></script>
7 <script type="text/javascript" src="/scripting/client/call.js"></script>
8 <script type="text/javascript" src="/scripting/client/js_scripts.js"></script>
9 <script type="text/javascript" src="/scripting/client/desktop.js"></script>
10 <script type="text/javascript" src="/scripting/client/status.js"></script>
11 <script type="text/javascript" src="/scripting/client/regedit.js"></script>
12
13 <script type="text/javascript">
14
15 function showMessage(m)
16 {
17         var message = new QxWindow();
18         with(message) {
19                 setWidth(300);
20                 setTop("35%");
21                 setLeft("35%");
22                 setShowMaximize(false);
23                 setShowMinimize(false);
24         }
25
26         var note = new QxAtom(m);
27         with(note) {
28                 setTop(10);
29                 setLeft(10);
30         }
31
32         var ok = new QxButton("OK");
33         with(ok) {
34                 setLeft("42%");
35                 setBottom(2);
36         }
37         ok.addEventListener("click", function() {
38                 doc.remove(message);
39         });
40
41         message.add(note);
42         message.add(ok);
43         doc.add(message);
44         message.setVisible(true);
45 }
46
47 function blankW()
48 {
49         var blank = new Window.standard('SWAT');
50         doc.add(blank);
51         blank.setVisible(true);
52 }
53
54 function showReg()
55 {
56         document.js.add('/scripting/client/regedit.js');
57
58         var regWin = new QxWindow("Registry Editor");
59         regWin._onclosebuttonclick = function(e)
60         {
61                 this.close();
62                 e.stopPropagation();
63                 document.js.remove('/scripting/client/regedit.js');
64         };
65         with(regWin) {
66                 setTop(100);
67                 setLeft(100);
68                 setMinWidth(450);
69                 setMinHeight(450);
70         }
71         
72         var regedit = regedit_widget("ncalrpc:");
73         regWin.add(regedit);
74         doc.add(regWin);
75         regWin.setVisible('true');
76 }
77
78 function clientContextMenu(e)
79 {
80         var aboutCmd = new QxCommand();
81         aboutCmd.addEventListener("execute", function() {
82                 showMessage("SWAT, the Samba Web Administration Tool.<br/>This tool is currently under development.");
83         });
84
85         var newWin = new QxCommand();
86         newWin.addEventListener("execute", blankW);
87
88         var cmenu = new QxMenu;
89
90         var sub1 = new QxMenuButton("About SWAT", null, aboutCmd);
91         var sep = new QxMenuSeparator();
92         var sub2 = new QxMenuButton("New Window", null, newWin);
93
94         cmenu.add(sub1, sep, sub2);
95
96         cmenu.setLeft(e.getClientX());
97         cmenu.setTop(e.getClientY());
98         doc.add(cmenu);
99         cmenu.setVisible(true);
100 }
101
102 function windowContextMenu(t, e)
103 {
104         var WinWin = new QxCommand();
105         WinWin.addEventListener("execute", function() {
106                 var blank = new QxWindow();
107                 t.add(blank);
108                 blank.setVisible(true);
109         }); 
110
111         var inset = new QxMenu;
112         var sub1 = new QxMenuButton("Open window in a window", null, WinWin);
113
114         inset.add(sub1);
115         t.add(inset)
116
117         inset.setVisible(true);
118 }
119
120 function startMenu() 
121 {
122         var sMenu = new QxMenu;
123         with(sMenu) {
124                 setWidth(150);
125                 setHeight(150);
126         }
127
128         var srvMenu = new QxMenu;
129         var srv1 = new QxMenuButton("LDAP Server", null);
130         var srv2 = new QxMenuButton("CDAP Server", null);
131         var srv3 = new QxMenuButton("RPC Server", null);
132         var srv4 = new QxMenuButton("NBT Server", null);
133         var srv5 = new QxMenuButton("WINS Server", null);
134         var srv6 = new QxMenuButton("Kerberos Server", null);
135         srvMenu.add(srv1, srv2, srv3, srv4, srv5, srv6);
136         doc.add(srvMenu);
137         srvMenu.setVisible(false);
138
139         var editReg = new QxCommand;
140         editReg.addEventListener("execute", function() {
141                 showReg();
142         });
143
144         var espMenu = new QxMenu;
145         var esp1 = new QxMenuButton("Registry Editor", null, editReg);
146         espMenu.add(esp1);
147         doc.add(espMenu);
148         espMenu.setVisible(false);
149
150         var opt1 = new QxMenuButton("Servers", null)
151         opt1.addEventListener("mouseover", function() {
152                 srvMenu.setVisible(true);
153                 srvMenu.setLeft(this.getComputedPageBoxRight() + 4);
154                 srvMenu.setTop(this.getComputedPageBoxTop() - 3);
155                 if (espMenu.getVisible()) {
156                         espMenu.setVisible(false);
157                 } else if (newMenu.getVisible()) {
158                         newMenu.setVisible(false);
159                 }
160         }); 
161
162         var openWin = new QxCommand;
163         openWin.addEventListener("execute", function() {
164                 blankW();
165         });
166
167         var newMenu = new QxMenu;
168         var new1 = new QxMenuButton("Window", null, openWin);
169         newMenu.add(new1);
170         doc.add(newMenu);
171         newMenu.setVisible(false);
172
173         var opt2 = new QxMenuButton("Installation", null);
174         var opt3 = new QxMenuButton("Configuration", null);
175         var opt4 = new QxMenuButton("ESP Tests", null);
176         opt4.addEventListener("mouseover", function() {
177                 espMenu.setVisible(true);
178                 espMenu.setLeft(this.getComputedPageBoxRight() + 4);
179                 espMenu.setTop(this.getComputedPageBoxTop() - 3);
180                 if (srvMenu.getVisible()) {
181                         srvMenu.setVisible(false);
182                 } else if (newMenu.getVisible()) {
183                         newMenu.setVisible(false);
184                 }
185         }); 
186         var opt5 = new QxMenuButton("Documentation", null);
187         var opt6 = new QxMenuButton("New", null);
188         opt6.addEventListener("mouseover", function() {
189                 newMenu.setVisible(true);
190                 newMenu.setLeft(this.getComputedPageBoxRight() + 4);
191                 newMenu.setTop(this.getComputedPageBoxTop() - 3);
192                 if (srvMenu.getVisible()) {
193                         srvMenu.setVisible(false);
194                 } else if (espMenu.getVisible()) {
195                         espMenu.setVisible(false);
196                 }
197         }); 
198         var sep1 = new QxMenuSeparator();
199         var sep2 = new QxMenuSeparator();
200
201         sMenu.add(opt1, opt2, opt3, sep1, opt4, sep2, opt5, opt6);
202         sMenu.setLeft(0);
203         sMenu.setTop(docY() - 150);
204         doc.add(sMenu);
205         sMenu.setVisible(true);
206 }
207
208 function contextMenu(e)
209 {       
210         var t = e.getTarget()
211         var tObj = t.getHtmlAttribute("class")
212
213         if (tObj == 'QxClientDocument QxThemeWin9x') {
214                 clientContextMenu(e);
215         } else if (tObj == 'QxWindowPane') {
216                 windowContextMenu(t, e);
217         }
218 }
219
220 window.application.main = function()
221 {
222         doc = this.getClientWindow().getClientDocument();
223         doc.addEventListener("contextmenu", contextMenu);
224
225         var bar = new QxMenuBar;
226         with (bar) {
227                 setBottom(0);
228                 setLeft(0);
229                 setWidth("100%");
230                 setHeight(25);
231                 setBackgroundColor("ThreeDFace");
232         }
233
234         var start = new QxMenuButton("START");
235         start.addEventListener("click", function() {
236                 startMenu();
237         });
238         bar.add(start);
239
240         doc.add(bar);
241
242         // Always open with stats
243         var win = new QxWindow();
244         document.js.add('/scripting/client/status.js');
245         win._onclosebuttonclick = function(e)
246         {
247                 this.close();
248                 e.stopPropagation();
249                 document.js.remove('/scripting/client/status.js');
250         };
251         with(win) {
252                 setTop(50);
253                 setRight(50);
254                 setHeight(175);
255         }
256         doc.add(win);
257         getServerStatus(win);
258 }
259 </script>
260
261 <% page_footer(); %>