r9635: Seperate window logic from registry js file.
[jra/samba/.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
10 <script type="text/javascript">
11
12 /* Qooxdoo's browser sniffer doesn't distinguish IE version.
13 We'll cover IE 6 for now, but these checks need to be
14 revisited for fuller browser coverage. */
15 var browser = QxClient().engine;
16
17 function docWidth()
18 {
19         var x;
20         if (browser != "mshtml") {
21                 x = window.innerWidth;
22         } else {
23                 x = document.documentElement.clientWidth;
24         }
25         return x;
26 }
27
28 function docHeight()
29 {
30         var y;
31         // Less 25px to not cover the toolbar
32         if (browser != "mshtml") {
33                 y = window.innerHeight - 25;
34         } else {
35                 y = document.documentElement.clientHeight;
36         }
37         return y;
38 }
39
40 function showMessage(m)
41 {
42         var message = new QxWindow();
43         with(message) {
44                 setWidth(300);
45                 setTop("35%");
46                 setLeft("35%");
47                 setShowMaximize(false);
48                 setShowMinimize(false);
49         }
50
51         var note = new QxAtom(m);
52         with(note) {
53                 setTop(10);
54                 setLeft(10);
55         }
56
57         var ok = new QxButton("OK");
58         with(ok) {
59                 setLeft("42%");
60                 setBottom(2);
61         }
62         ok.addEventListener("click", function() {
63                 w.remove(message);
64         });
65
66         message.add(note);
67         message.add(ok);
68         w.add(message);
69         message.setVisible(true);
70 }
71
72 function showContextMenu(e)
73 {
74         var aboutCmd = new QxCommand();
75         aboutCmd.addEventListener("execute", function() {
76                 showMessage("SWAT, the Samba Web Administration Tool.<br/>This tool is currently under development.");
77         });
78
79         var menu = new QxMenu;
80
81         var sub1 = new QxMenuButton("About SWAT", null, aboutCmd);
82         var sep = new QxMenuSeparator();
83         var sub2 = new QxMenuButton("More menu later...", null);
84
85         menu.add(sub1, sep, sub2);
86
87         menu.setLeft(e.getClientX());
88         menu.setTop(e.getClientY());
89         w.add(menu);
90         menu.setVisible(true);
91 }
92
93 /*** init the page for qooxdoo ***/
94 document.js.add('/scripting/client/status.js');
95 window.application.main = function()
96 {
97         var doc = this.getClientWindow().getClientDocument();
98         // Don't declare local with var
99         w = new QxWidget();
100         with(w) {
101                 setTop(0);
102                 setLeft(0);
103                 setWidth(docWidth());
104                 setHeight(docHeight());
105         }
106         doc.addEventListener("contextmenu", showContextMenu);
107         doc.add(w);
108
109
110         // Always open with stats
111         var win = new QxWindow();
112         win._onclosebuttonclick = function(e)
113         {
114                 this.close();
115                 e.stopPropagation();
116                 document.js.remove('/scripting/client/status.js');
117         };
118         with(win) {
119                 setTop(50);
120                 setRight(50);
121                 setHeight(175);
122         }
123         w.add(win);
124         getServerStatus(win);
125         
126 }
127
128 window.onresize = function() 
129 {
130         w.setWidth(docWidth());
131         w.setHeight(docHeight());
132 }
133
134 function showReg()
135 {
136         document.js.add('/scripting/client/regedit.js');
137
138         var regWin = new QxWindow("Registry Editor");
139         regWin._onclosebuttonclick = function(e)
140         {
141                 this.close();
142                 e.stopPropagation();
143                 document.js.remove('/scripting/client/regedit.js');
144         };
145         with(regWin) {
146                 setTop(100);
147                 setLeft(100);
148                 setMinWidth(450);
149                 setMinHeight(450);
150         }
151         
152         var regedit = regedit_widget("ncalrpc:");
153         regWin.add(regedit);
154         w.add(regWin);
155         regWin.setVisible('true');
156 }
157
158 function startSwat()
159 {
160         var sMenu = new QxMenu;
161         with(sMenu) {
162                 setWidth(150);
163                 setHeight(150);
164         }
165
166         var srvMenu = new QxMenu;
167         var srv1 = new QxMenuButton("LDAP Server", null);
168         var srv2 = new QxMenuButton("CDAP Server", null);
169         var srv3 = new QxMenuButton("RPC Server", null);
170         var srv4 = new QxMenuButton("NBT Server", null);
171         var srv5 = new QxMenuButton("WINS Server", null);
172         var srv6 = new QxMenuButton("Kerberos Server", null);
173         srvMenu.add(srv1, srv2, srv3, srv4, srv5, srv6);
174         w.add(srvMenu);
175         srvMenu.setVisible(false);
176
177         var editReg = new QxCommand;
178         editReg.addEventListener("execute", function() {
179                 showReg();
180         });
181
182         var espMenu = new QxMenu;
183         var esp1 = new QxMenuButton("Registry Editor", null, editReg);
184         espMenu.add(esp1);
185         w.add(espMenu);
186         espMenu.setVisible(false);
187
188         var opt1 = new QxMenuButton("Servers", null)
189         opt1.addEventListener("mouseover", function() {
190                 srvMenu.setVisible(true);
191                 srvMenu.setLeft(this.getComputedPageBoxRight() + 4);
192                 srvMenu.setTop(this.getComputedPageBoxTop() - 3);
193                 if (espMenu.getVisible()) {
194                         espMenu.setVisible(false);
195                 }
196         }); 
197         var opt2 = new QxMenuButton("Installation", null);
198         var opt3 = new QxMenuButton("Configuration", null);
199         var opt4 = new QxMenuButton("ESP Tests", null);
200         opt4.addEventListener("mouseover", function() {
201                 espMenu.setVisible(true);
202                 espMenu.setLeft(this.getComputedPageBoxRight() + 4);
203                 espMenu.setTop(this.getComputedPageBoxTop() - 3);
204                 if (srvMenu.getVisible()) {
205                         srvMenu.setVisible(false);
206                 }
207         }); 
208         var opt5 = new QxMenuButton("Documentation", null);
209         var sep1 = new QxMenuSeparator();
210         var sep2 = new QxMenuSeparator();
211
212         sMenu.add(opt1, opt2, opt3, sep1, opt4, sep2, opt5);
213         sMenu.setLeft(0);
214         sMenu.setTop(docHeight() - 150);
215         w.add(sMenu);
216         sMenu.setVisible(true);
217 }
218 </script>
219
220 <div id="toolbar">
221 <h3><a href="javascript:startSwat()">SWAT (Start)</a></h3>
222 </div>
223
224 <% page_footer(); %>