]> git.proxmox.com Git - mirror_novnc.git/blob - vnc_auto.html
Remove unnecessary substates of disconnected
[mirror_novnc.git] / vnc_auto.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4
5 <!--
6 noVNC example: simple example using default UI
7 Copyright (C) 2012 Joel Martin
8 Copyright (C) 2013 Samuel Mannehed for Cendio AB
9 noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
10 This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
11
12 Connect parameters are provided in query string:
13 http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
14 or the fragment:
15 http://example.com/#host=HOST&port=PORT&encrypt=1&true_color=1
16 -->
17 <title>noVNC</title>
18
19 <meta charset="utf-8">
20
21 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
22 Remove this if you use the .htaccess -->
23 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
24
25 <!-- Apple iOS Safari settings -->
26 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
27 <meta name="apple-mobile-web-app-capable" content="yes" />
28 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
29 <!-- App Start Icon -->
30 <link rel="apple-touch-startup-image" href="app/images/screen_320x460.png" />
31 <!-- For iOS devices set the icon to use if user bookmarks app on their homescreen -->
32 <link rel="apple-touch-icon" href="app/images/screen_57x57.png">
33 <!--
34 <link rel="apple-touch-icon-precomposed" href="app/images/screen_57x57.png" />
35 -->
36
37
38 <!-- Stylesheets -->
39 <link rel="stylesheet" href="app/styles/auto.css">
40
41 <!--
42 <script type='text/javascript'
43 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
44 -->
45 <script src="core/util.js"></script>
46 <script src="app/webutil.js"></script>
47 </head>
48
49 <body style="margin: 0px;">
50 <div id="noVNC_container">
51 <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
52 <table border=0 width="100%"><tr>
53 <td><div id="noVNC_status" style="position: relative; height: auto;">
54 Loading
55 </div></td>
56 <td width="1%"><div id="noVNC_buttons">
57 <input type=button value="Send CtrlAltDel"
58 id="sendCtrlAltDelButton">
59 <span id="noVNC_xvp_buttons">
60 <input type=button value="Shutdown"
61 id="xvpShutdownButton">
62 <input type=button value="Reboot"
63 id="xvpRebootButton">
64 <input type=button value="Reset"
65 id="xvpResetButton">
66 </span>
67 </div></td>
68 </tr></table>
69 </div>
70 <canvas id="noVNC_canvas" width="640px" height="20px">
71 Canvas not supported.
72 </canvas>
73 </div>
74
75 <script>
76 /*jslint white: false */
77 /*global window, $, Util, RFB, */
78 "use strict";
79
80 // Load supporting scripts
81 WebUtil.load_scripts({
82 'core': ["base64.js", "websock.js", "des.js", "input/keysymdef.js",
83 "input/xtscancodes.js", "input/util.js", "input/devices.js",
84 "display.js", "inflator.js", "rfb.js", "input/keysym.js"],
85 'app': ["webutil.js"]});
86
87 var rfb;
88 var resizeTimeout;
89 var desktopName;
90
91
92 function UIresize() {
93 if (WebUtil.getConfigVar('resize', false)) {
94 var innerW = window.innerWidth;
95 var innerH = window.innerHeight;
96 var controlbarH = document.getElementById('noVNC_status_bar').offsetHeight;
97 var padding = 5;
98 if (innerW !== undefined && innerH !== undefined)
99 rfb.requestDesktopSize(innerW, innerH - controlbarH - padding);
100 }
101 }
102 function FBUComplete(rfb, fbu) {
103 UIresize();
104 rfb.set_onFBUComplete(function() { });
105 }
106 function updateDesktopName(rfb, name) {
107 desktopName = name;
108 }
109 function passwordRequired(rfb, msg) {
110 if (typeof msg === 'undefined') {
111 msg = 'Password Required: ';
112 }
113 var html;
114 html = '<form onsubmit="return setPassword();"';
115 html += ' style="margin-bottom: 0px">';
116 html += msg;
117 html += '<input type=password size=10 id="password_input" class="noVNC_status">';
118 html += '<\/form>';
119 status(html, "warn");
120 }
121 function setPassword() {
122 rfb.sendPassword(document.getElementById('password_input').value);
123 return false;
124 }
125 function sendCtrlAltDel() {
126 rfb.sendCtrlAltDel();
127 return false;
128 }
129 function xvpShutdown() {
130 rfb.xvpShutdown();
131 return false;
132 }
133 function xvpReboot() {
134 rfb.xvpReboot();
135 return false;
136 }
137 function xvpReset() {
138 rfb.xvpReset();
139 return false;
140 }
141 function status(text, level) {
142 switch (level) {
143 case 'normal':
144 case 'warn':
145 case 'error':
146 break;
147 default:
148 level = "warn";
149 }
150 document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_" + level);
151 document.getElementById('noVNC_status').innerHTML = text;
152 }
153 function updateState(rfb, state, oldstate) {
154 var cad = document.getElementById('sendCtrlAltDelButton');
155 var encrypt = (rfb && rfb.get_encrypt()) ? 'encrypted' : 'unencrypted';
156 switch (state) {
157 case 'connecting':
158 status("Connecting", "normal");
159 break;
160 case 'connected':
161 status("Connected (" + encrypt + ") to: " + desktopName, "normal");
162 break;
163 case 'disconnecting':
164 status("Disconnecting", "normal");
165 break;
166 case 'disconnected':
167 status("Disconnected", "normal");
168 break;
169 default:
170 status(state, "warn");
171 break;
172 }
173
174 if (state === 'connected') {
175 cad.disabled = false;
176 } else {
177 cad.disabled = true;
178 xvpInit(0);
179 }
180
181 }
182 function disconnected(rfb, reason) {
183 if (typeof(reason) !== 'undefined') {
184 status(reason, "error");
185 }
186 }
187 function notification(rfb, msg, level, options) {
188 status(msg, level);
189 }
190
191 window.onresize = function () {
192 // When the window has been resized, wait until the size remains
193 // the same for 0.5 seconds before sending the request for changing
194 // the resolution of the session
195 clearTimeout(resizeTimeout);
196 resizeTimeout = setTimeout(function(){
197 UIresize();
198 }, 500);
199 };
200
201 function xvpInit(ver) {
202 var xvpbuttons;
203 xvpbuttons = document.getElementById('noVNC_xvp_buttons');
204 if (ver >= 1) {
205 xvpbuttons.style.display = 'inline';
206 } else {
207 xvpbuttons.style.display = 'none';
208 }
209 }
210
211 window.onscriptsload = function () {
212 var host, port, password, path, token;
213
214 document.getElementById('sendCtrlAltDelButton').style.display = "inline";
215 document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
216 document.getElementById('xvpShutdownButton').onclick = xvpShutdown;
217 document.getElementById('xvpRebootButton').onclick = xvpReboot;
218 document.getElementById('xvpResetButton').onclick = xvpReset;
219
220 WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn'));
221 document.title = unescape(WebUtil.getConfigVar('title', 'noVNC'));
222 // By default, use the host and port of server that served this file
223 host = WebUtil.getConfigVar('host', window.location.hostname);
224 port = WebUtil.getConfigVar('port', window.location.port);
225
226 // if port == 80 (or 443) then it won't be present and should be
227 // set manually
228 if (!port) {
229 if (window.location.protocol.substring(0,5) == 'https') {
230 port = 443;
231 }
232 else if (window.location.protocol.substring(0,4) == 'http') {
233 port = 80;
234 }
235 }
236
237 password = WebUtil.getConfigVar('password', '');
238 path = WebUtil.getConfigVar('path', 'websockify');
239
240 // If a token variable is passed in, set the parameter in a cookie.
241 // This is used by nova-novncproxy.
242 token = WebUtil.getConfigVar('token', null);
243 if (token) {
244
245 // if token is already present in the path we should use it
246 path = WebUtil.injectParamIfMissing(path, "token", token);
247
248 WebUtil.createCookie('token', token, 1)
249 }
250
251 if ((!host) || (!port)) {
252 status('Must specify host and port in URL', 'error');
253 return;
254 }
255
256 try {
257 rfb = new RFB({'target': document.getElementById('noVNC_canvas'),
258 'encrypt': WebUtil.getConfigVar('encrypt',
259 (window.location.protocol === "https:")),
260 'repeaterID': WebUtil.getConfigVar('repeaterID', ''),
261 'true_color': WebUtil.getConfigVar('true_color', true),
262 'local_cursor': WebUtil.getConfigVar('cursor', true),
263 'shared': WebUtil.getConfigVar('shared', true),
264 'view_only': WebUtil.getConfigVar('view_only', false),
265 'onNotification': notification,
266 'onUpdateState': updateState,
267 'onDisconnected': disconnected,
268 'onXvpInit': xvpInit,
269 'onPasswordRequired': passwordRequired,
270 'onFBUComplete': FBUComplete,
271 'onDesktopName': updateDesktopName});
272 } catch (exc) {
273 status('Unable to create RFB client -- ' + exc, 'error');
274 return; // don't continue trying to connect
275 }
276
277 rfb.connect(host, port, password, path);
278 };
279 </script>
280
281 </body>
282 </html>