]> git.proxmox.com Git - mirror_novnc.git/blob - vnc_auto.html
QEMU RFB extension - new file xtscancodes.js
[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="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="images/screen_57x57.png">
33 <!--
34 <link rel="apple-touch-icon-precomposed" href="images/screen_57x57.png" />
35 -->
36
37
38 <!-- Stylesheets -->
39 <link rel="stylesheet" href="include/base.css" title="plain">
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="include/util.js"></script>
46 </head>
47
48 <body style="margin: 0px;">
49 <div id="noVNC_container">
50 <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
51 <table border=0 width="100%"><tr>
52 <td><div id="noVNC_status" style="position: relative; height: auto;">
53 Loading
54 </div></td>
55 <td width="1%"><div id="noVNC_buttons">
56 <input type=button value="Send CtrlAltDel"
57 id="sendCtrlAltDelButton">
58 <span id="noVNC_xvp_buttons">
59 <input type=button value="Shutdown"
60 id="xvpShutdownButton">
61 <input type=button value="Reboot"
62 id="xvpRebootButton">
63 <input type=button value="Reset"
64 id="xvpResetButton">
65 </span>
66 </div></td>
67 </tr></table>
68 </div>
69 <canvas id="noVNC_canvas" width="640px" height="20px">
70 Canvas not supported.
71 </canvas>
72 </div>
73
74 <script>
75 /*jslint white: false */
76 /*global window, $, Util, RFB, */
77 "use strict";
78
79 // Load supporting scripts
80 Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
81 "keysymdef.js", "xtscancodes.js", "keyboard.js",
82 "input.js", "display.js", "inflator.js", "rfb.js",
83 "keysym.js"]);
84
85 var rfb;
86 var resizeTimeout;
87
88
89 function UIresize() {
90 if (WebUtil.getConfigVar('resize', false)) {
91 var innerW = window.innerWidth;
92 var innerH = window.innerHeight;
93 var controlbarH = $D('noVNC_status_bar').offsetHeight;
94 var padding = 5;
95 if (innerW !== undefined && innerH !== undefined)
96 rfb.requestDesktopSize(innerW, innerH - controlbarH - padding);
97 }
98 }
99 function FBUComplete(rfb, fbu) {
100 UIresize();
101 rfb.set_onFBUComplete(function() { });
102 }
103 function passwordRequired(rfb) {
104 var msg;
105 msg = '<form onsubmit="return setPassword();"';
106 msg += ' style="margin-bottom: 0px">';
107 msg += 'Password Required: ';
108 msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
109 msg += '<\/form>';
110 $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
111 $D('noVNC_status').innerHTML = msg;
112 }
113 function setPassword() {
114 rfb.sendPassword($D('password_input').value);
115 return false;
116 }
117 function sendCtrlAltDel() {
118 rfb.sendCtrlAltDel();
119 return false;
120 }
121 function xvpShutdown() {
122 rfb.xvpShutdown();
123 return false;
124 }
125 function xvpReboot() {
126 rfb.xvpReboot();
127 return false;
128 }
129 function xvpReset() {
130 rfb.xvpReset();
131 return false;
132 }
133 function updateState(rfb, state, oldstate, msg) {
134 var s, sb, cad, level;
135 s = $D('noVNC_status');
136 sb = $D('noVNC_status_bar');
137 cad = $D('sendCtrlAltDelButton');
138 switch (state) {
139 case 'failed': level = "error"; break;
140 case 'fatal': level = "error"; break;
141 case 'normal': level = "normal"; break;
142 case 'disconnected': level = "normal"; break;
143 case 'loaded': level = "normal"; break;
144 default: level = "warn"; break;
145 }
146
147 if (state === "normal") {
148 cad.disabled = false;
149 } else {
150 cad.disabled = true;
151 xvpInit(0);
152 }
153
154 if (typeof(msg) !== 'undefined') {
155 sb.setAttribute("class", "noVNC_status_" + level);
156 s.innerHTML = msg;
157 }
158 }
159
160 window.onresize = function () {
161 // When the window has been resized, wait until the size remains
162 // the same for 0.5 seconds before sending the request for changing
163 // the resolution of the session
164 clearTimeout(resizeTimeout);
165 resizeTimeout = setTimeout(function(){
166 UIresize();
167 }, 500);
168 };
169
170 function xvpInit(ver) {
171 var xvpbuttons;
172 xvpbuttons = $D('noVNC_xvp_buttons');
173 if (ver >= 1) {
174 xvpbuttons.style.display = 'inline';
175 } else {
176 xvpbuttons.style.display = 'none';
177 }
178 }
179
180 window.onscriptsload = function () {
181 var host, port, password, path, token;
182
183 $D('sendCtrlAltDelButton').style.display = "inline";
184 $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
185 $D('xvpShutdownButton').onclick = xvpShutdown;
186 $D('xvpRebootButton').onclick = xvpReboot;
187 $D('xvpResetButton').onclick = xvpReset;
188
189 WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn'));
190 document.title = unescape(WebUtil.getConfigVar('title', 'noVNC'));
191 // By default, use the host and port of server that served this file
192 host = WebUtil.getConfigVar('host', window.location.hostname);
193 port = WebUtil.getConfigVar('port', window.location.port);
194
195 // if port == 80 (or 443) then it won't be present and should be
196 // set manually
197 if (!port) {
198 if (window.location.protocol.substring(0,5) == 'https') {
199 port = 443;
200 }
201 else if (window.location.protocol.substring(0,4) == 'http') {
202 port = 80;
203 }
204 }
205
206 password = WebUtil.getConfigVar('password', '');
207 path = WebUtil.getConfigVar('path', 'websockify');
208
209 // If a token variable is passed in, set the parameter in a cookie.
210 // This is used by nova-novncproxy.
211 token = WebUtil.getConfigVar('token', null);
212 if (token) {
213
214 // if token is already present in the path we should use it
215 path = WebUtil.injectParamIfMissing(path, "token", token);
216
217 WebUtil.createCookie('token', token, 1)
218 }
219
220 if ((!host) || (!port)) {
221 updateState(null, 'fatal', null, 'Must specify host and port in URL');
222 return;
223 }
224
225 try {
226 rfb = new RFB({'target': $D('noVNC_canvas'),
227 'encrypt': WebUtil.getConfigVar('encrypt',
228 (window.location.protocol === "https:")),
229 'repeaterID': WebUtil.getConfigVar('repeaterID', ''),
230 'true_color': WebUtil.getConfigVar('true_color', true),
231 'local_cursor': WebUtil.getConfigVar('cursor', true),
232 'shared': WebUtil.getConfigVar('shared', true),
233 'view_only': WebUtil.getConfigVar('view_only', false),
234 'onUpdateState': updateState,
235 'onXvpInit': xvpInit,
236 'onPasswordRequired': passwordRequired,
237 'onFBUComplete': FBUComplete});
238 } catch (exc) {
239 updateState(null, 'fatal', null, 'Unable to create RFB client -- ' + exc);
240 return; // don't continue trying to connect
241 }
242
243 rfb.connect(host, port, password, path);
244 };
245 </script>
246
247 </body>
248 </html>