]> git.proxmox.com Git - mirror_novnc.git/blame - vnc_auto.html
Clean up unused files in tests
[mirror_novnc.git] / vnc_auto.html
CommitLineData
40f281eb 1<!DOCTYPE html>
91308399 2<html>
e84101b3
3<head>
4
82744aa8 5 <!--
d58f8b51
JM
6 noVNC example: simple example using default UI
7 Copyright (C) 2012 Joel Martin
0019d3b0 8 Copyright (C) 2013 Samuel Mannehed for Cendio AB
1d728ace 9 noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
d58f8b51 10 This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
d595e656
JM
11
12 Connect parameters are provided in query string:
13 http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
494b407a
GV
14 or the fragment:
15 http://example.com/#host=HOST&port=PORT&encrypt=1&true_color=1
d595e656 16 -->
e84101b3
17 <title>noVNC</title>
18
33f5d3bd
19 <meta charset="utf-8">
20
e84101b3
21 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
22 Remove this if you use the .htaccess -->
33f5d3bd
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 -->
ae510306 30 <link rel="apple-touch-startup-image" href="app/images/screen_320x460.png" />
33f5d3bd 31 <!-- For iOS devices set the icon to use if user bookmarks app on their homescreen -->
ae510306 32 <link rel="apple-touch-icon" href="app/images/screen_57x57.png">
33f5d3bd 33 <!--
ae510306 34 <link rel="apple-touch-icon-precomposed" href="app/images/screen_57x57.png" />
33f5d3bd 35 -->
e84101b3
36
37
38 <!-- Stylesheets -->
ae510306 39 <link rel="stylesheet" href="app/styles/base.css" title="plain">
e84101b3
40
41 <!--
42 <script type='text/javascript'
43 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
44 -->
ae510306 45 <script src="core/util.js"></script>
e84101b3 46</head>
91308399 47
e84101b3 48<body style="margin: 0px;">
3daa86cb 49 <div id="noVNC_container">
a7f55899 50 <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
8db09746 51 <table border=0 width="100%"><tr>
35b29c98 52 <td><div id="noVNC_status" style="position: relative; height: auto;">
53 Loading
54 </div></td>
a7f55899 55 <td width="1%"><div id="noVNC_buttons">
63708ff5 56 <input type=button value="Send CtrlAltDel"
8db09746 57 id="sendCtrlAltDelButton">
fb35d50f
MS
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>
8db09746 66 </div></td>
63708ff5
JM
67 </tr></table>
68 </div>
a7f55899 69 <canvas id="noVNC_canvas" width="640px" height="20px">
91308399
JM
70 Canvas not supported.
71 </canvas>
72 </div>
91308399 73
8db09746
JM
74 <script>
75 /*jslint white: false */
76 /*global window, $, Util, RFB, */
77 "use strict";
78
6f4b1e40 79 // Load supporting scripts
ae510306
SR
80 Util.load_scripts({
81 'core': ["base64.js", "websock.js", "des.js", "keysymdef.js",
82 "xtscancodes.js", "keyboard.js", "input.js", "display.js",
83 "inflator.js", "rfb.js", "keysym.js"],
84 'app': ["webutil.js"]});
6f4b1e40 85
8db09746 86 var rfb;
f8b399d7 87 var resizeTimeout;
8db09746 88
f8b399d7 89
90 function UIresize() {
494b407a 91 if (WebUtil.getConfigVar('resize', false)) {
f8b399d7 92 var innerW = window.innerWidth;
93 var innerH = window.innerHeight;
ae510306 94 var controlbarH = document.getElementById('noVNC_status_bar').offsetHeight;
f8b399d7 95 var padding = 5;
96 if (innerW !== undefined && innerH !== undefined)
ae116051 97 rfb.requestDesktopSize(innerW, innerH - controlbarH - padding);
f8b399d7 98 }
99 }
100 function FBUComplete(rfb, fbu) {
101 UIresize();
102 rfb.set_onFBUComplete(function() { });
103 }
d890e864
JM
104 function passwordRequired(rfb) {
105 var msg;
106 msg = '<form onsubmit="return setPassword();"';
107 msg += ' style="margin-bottom: 0px">';
108 msg += 'Password Required: ';
a7f55899 109 msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
d890e864 110 msg += '<\/form>';
ae510306
SR
111 document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
112 document.getElementById('noVNC_status').innerHTML = msg;
d890e864 113 }
91308399 114 function setPassword() {
ae510306 115 rfb.sendPassword(document.getElementById('password_input').value);
91308399
JM
116 return false;
117 }
63708ff5 118 function sendCtrlAltDel() {
8db09746 119 rfb.sendCtrlAltDel();
a8edf9d8 120 return false;
63708ff5 121 }
fb35d50f
MS
122 function xvpShutdown() {
123 rfb.xvpShutdown();
124 return false;
125 }
126 function xvpReboot() {
127 rfb.xvpReboot();
128 return false;
129 }
130 function xvpReset() {
131 rfb.xvpReset();
132 return false;
133 }
8db09746 134 function updateState(rfb, state, oldstate, msg) {
d890e864 135 var s, sb, cad, level;
ae510306
SR
136 s = document.getElementById('noVNC_status');
137 sb = document.getElementById('noVNC_status_bar');
138 cad = document.getElementById('sendCtrlAltDelButton');
91308399 139 switch (state) {
d890e864
JM
140 case 'failed': level = "error"; break;
141 case 'fatal': level = "error"; break;
142 case 'normal': level = "normal"; break;
143 case 'disconnected': level = "normal"; break;
144 case 'loaded': level = "normal"; break;
145 default: level = "warn"; break;
91308399
JM
146 }
147
fb35d50f
MS
148 if (state === "normal") {
149 cad.disabled = false;
150 } else {
151 cad.disabled = true;
152 xvpInit(0);
153 }
160fabf6 154
91308399 155 if (typeof(msg) !== 'undefined') {
a7f55899 156 sb.setAttribute("class", "noVNC_status_" + level);
91308399
JM
157 s.innerHTML = msg;
158 }
91308399
JM
159 }
160
f8b399d7 161 window.onresize = function () {
162 // When the window has been resized, wait until the size remains
163 // the same for 0.5 seconds before sending the request for changing
164 // the resolution of the session
165 clearTimeout(resizeTimeout);
166 resizeTimeout = setTimeout(function(){
167 UIresize();
168 }, 500);
169 };
170
fb35d50f
MS
171 function xvpInit(ver) {
172 var xvpbuttons;
ae510306 173 xvpbuttons = document.getElementById('noVNC_xvp_buttons');
fb35d50f
MS
174 if (ver >= 1) {
175 xvpbuttons.style.display = 'inline';
176 } else {
177 xvpbuttons.style.display = 'none';
178 }
179 }
180
6f4b1e40 181 window.onscriptsload = function () {
9ebc84f2 182 var host, port, password, path, token;
91308399 183
ae510306
SR
184 document.getElementById('sendCtrlAltDelButton').style.display = "inline";
185 document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
186 document.getElementById('xvpShutdownButton').onclick = xvpShutdown;
187 document.getElementById('xvpRebootButton').onclick = xvpReboot;
188 document.getElementById('xvpResetButton').onclick = xvpReset;
8db09746 189
494b407a
GV
190 WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn'));
191 document.title = unescape(WebUtil.getConfigVar('title', 'noVNC'));
bd96e919 192 // By default, use the host and port of server that served this file
494b407a
GV
193 host = WebUtil.getConfigVar('host', window.location.hostname);
194 port = WebUtil.getConfigVar('port', window.location.port);
0139b256 195
e83b9e03
WR
196 // if port == 80 (or 443) then it won't be present and should be
197 // set manually
198 if (!port) {
82744aa8 199 if (window.location.protocol.substring(0,5) == 'https') {
e83b9e03
WR
200 port = 443;
201 }
82744aa8 202 else if (window.location.protocol.substring(0,4) == 'http') {
eb955f8c
JD
203 port = 80;
204 }
e83b9e03
WR
205 }
206
c55f05f6
MXPN
207 password = WebUtil.getConfigVar('password', '');
208 path = WebUtil.getConfigVar('path', 'websockify');
209
0139b256
AY
210 // If a token variable is passed in, set the parameter in a cookie.
211 // This is used by nova-novncproxy.
494b407a 212 token = WebUtil.getConfigVar('token', null);
0139b256 213 if (token) {
c55f05f6
MXPN
214
215 // if token is already present in the path we should use it
216 path = WebUtil.injectParamIfMissing(path, "token", token);
217
0139b256
AY
218 WebUtil.createCookie('token', token, 1)
219 }
220
91308399 221 if ((!host) || (!port)) {
2bcfd586 222 updateState(null, 'fatal', null, 'Must specify host and port in URL');
91308399
JM
223 return;
224 }
225
d9fc1c7b 226 try {
ae510306 227 rfb = new RFB({'target': document.getElementById('noVNC_canvas'),
494b407a 228 'encrypt': WebUtil.getConfigVar('encrypt',
d9fc1c7b 229 (window.location.protocol === "https:")),
494b407a
GV
230 'repeaterID': WebUtil.getConfigVar('repeaterID', ''),
231 'true_color': WebUtil.getConfigVar('true_color', true),
232 'local_cursor': WebUtil.getConfigVar('cursor', true),
233 'shared': WebUtil.getConfigVar('shared', true),
234 'view_only': WebUtil.getConfigVar('view_only', false),
d9fc1c7b
SR
235 'onUpdateState': updateState,
236 'onXvpInit': xvpInit,
237 'onPasswordRequired': passwordRequired,
238 'onFBUComplete': FBUComplete});
239 } catch (exc) {
2bcfd586 240 updateState(null, 'fatal', null, 'Unable to create RFB client -- ' + exc);
d9fc1c7b
SR
241 return; // don't continue trying to connect
242 }
243
9ebc84f2 244 rfb.connect(host, port, password, path);
8db09746
JM
245 };
246 </script>
da6dd893 247
8db09746 248 </body>
91308399 249</html>