]>
Commit | Line | Data |
---|---|---|
40f281eb | 1 | <!DOCTYPE html> |
91308399 | 2 | <html> |
e84101b3 PÅ |
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 PÅ |
17 | <title>noVNC</title> |
18 | ||
33f5d3bd PÅ |
19 | <meta charset="utf-8"> |
20 | ||
e84101b3 PÅ |
21 | <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame |
22 | Remove this if you use the .htaccess --> | |
33f5d3bd PÅ |
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 PÅ |
36 | |
37 | ||
38 | <!-- Stylesheets --> | |
ecd49c15 | 39 | <link rel="stylesheet" href="app/styles/auto.css"> |
e84101b3 PÅ |
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> |
72bdd06e | 46 | <script src="app/webutil.js"></script> |
e84101b3 | 47 | </head> |
91308399 | 48 | |
e84101b3 | 49 | <body style="margin: 0px;"> |
3daa86cb | 50 | <div id="noVNC_container"> |
a7f55899 | 51 | <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;"> |
8db09746 | 52 | <table border=0 width="100%"><tr> |
35b29c98 | 53 | <td><div id="noVNC_status" style="position: relative; height: auto;"> |
54 | Loading | |
55 | </div></td> | |
a7f55899 | 56 | <td width="1%"><div id="noVNC_buttons"> |
63708ff5 | 57 | <input type=button value="Send CtrlAltDel" |
8db09746 | 58 | id="sendCtrlAltDelButton"> |
fb35d50f MS |
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> | |
8db09746 | 67 | </div></td> |
63708ff5 JM |
68 | </tr></table> |
69 | </div> | |
a7f55899 | 70 | <canvas id="noVNC_canvas" width="640px" height="20px"> |
91308399 JM |
71 | Canvas not supported. |
72 | </canvas> | |
73 | </div> | |
91308399 | 74 | |
8db09746 JM |
75 | <script> |
76 | /*jslint white: false */ | |
77 | /*global window, $, Util, RFB, */ | |
78 | "use strict"; | |
79 | ||
6f4b1e40 | 80 | // Load supporting scripts |
72bdd06e | 81 | WebUtil.load_scripts({ |
bd5340c7 SR |
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"], | |
733d5009 | 85 | 'app': [WebUtil.getLanguageFileLocation(), "webutil.js"]}); |
6f4b1e40 | 86 | |
8db09746 | 87 | var rfb; |
f8b399d7 | 88 | var resizeTimeout; |
3bb12056 | 89 | var desktopName; |
8db09746 | 90 | |
f8b399d7 | 91 | |
92 | function UIresize() { | |
494b407a | 93 | if (WebUtil.getConfigVar('resize', false)) { |
f8b399d7 | 94 | var innerW = window.innerWidth; |
95 | var innerH = window.innerHeight; | |
ae510306 | 96 | var controlbarH = document.getElementById('noVNC_status_bar').offsetHeight; |
f8b399d7 | 97 | if (innerW !== undefined && innerH !== undefined) |
67453ade | 98 | rfb.requestDesktopSize(innerW, innerH - controlbarH); |
f8b399d7 | 99 | } |
100 | } | |
101 | function FBUComplete(rfb, fbu) { | |
102 | UIresize(); | |
103 | rfb.set_onFBUComplete(function() { }); | |
104 | } | |
3bb12056 SM |
105 | function updateDesktopName(rfb, name) { |
106 | desktopName = name; | |
107 | } | |
7d714b15 SM |
108 | function passwordRequired(rfb, msg) { |
109 | if (typeof msg === 'undefined') { | |
110 | msg = 'Password Required: '; | |
111 | } | |
112 | var html; | |
113 | html = '<form onsubmit="return setPassword();"'; | |
114 | html += ' style="margin-bottom: 0px">'; | |
115 | html += msg; | |
116 | html += '<input type=password size=10 id="password_input" class="noVNC_status">'; | |
117 | html += '<\/form>'; | |
3bb12056 | 118 | status(html, "warn"); |
d890e864 | 119 | } |
91308399 | 120 | function setPassword() { |
ae510306 | 121 | rfb.sendPassword(document.getElementById('password_input').value); |
91308399 JM |
122 | return false; |
123 | } | |
63708ff5 | 124 | function sendCtrlAltDel() { |
8db09746 | 125 | rfb.sendCtrlAltDel(); |
a8edf9d8 | 126 | return false; |
63708ff5 | 127 | } |
fb35d50f MS |
128 | function xvpShutdown() { |
129 | rfb.xvpShutdown(); | |
130 | return false; | |
131 | } | |
132 | function xvpReboot() { | |
133 | rfb.xvpReboot(); | |
134 | return false; | |
135 | } | |
136 | function xvpReset() { | |
137 | rfb.xvpReset(); | |
138 | return false; | |
139 | } | |
3bb12056 SM |
140 | function status(text, level) { |
141 | switch (level) { | |
142 | case 'normal': | |
143 | case 'warn': | |
144 | case 'error': | |
145 | break; | |
146 | default: | |
147 | level = "warn"; | |
148 | } | |
149 | document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_" + level); | |
150 | document.getElementById('noVNC_status').innerHTML = text; | |
151 | } | |
152 | function updateState(rfb, state, oldstate) { | |
153 | var cad = document.getElementById('sendCtrlAltDelButton'); | |
91308399 | 154 | switch (state) { |
3bb12056 | 155 | case 'connecting': |
733d5009 | 156 | status(Util.Localisation.get("Connecting"), "normal"); |
3bb12056 SM |
157 | break; |
158 | case 'connected': | |
733d5009 SM |
159 | if (rfb && rfb.get_encrypt()) { |
160 | status(Util.Localisation. | |
161 | get("Connected (encrypted) to ") + | |
162 | desktopName, "normal"); | |
163 | } else { | |
164 | status(Util.Localisation. | |
165 | get("Connected (unencrypted) to ") + | |
166 | desktopName, "normal"); | |
167 | } | |
3bb12056 SM |
168 | break; |
169 | case 'disconnecting': | |
733d5009 | 170 | status(Util.Localisation.get("Disconnecting"), "normal"); |
3bb12056 SM |
171 | break; |
172 | case 'disconnected': | |
733d5009 | 173 | status(Util.Localisation.get("Disconnected"), "normal"); |
3bb12056 SM |
174 | break; |
175 | default: | |
176 | status(state, "warn"); | |
177 | break; | |
91308399 JM |
178 | } |
179 | ||
c2a4d3ef | 180 | if (state === 'connected') { |
fb35d50f MS |
181 | cad.disabled = false; |
182 | } else { | |
183 | cad.disabled = true; | |
184 | xvpInit(0); | |
185 | } | |
160fabf6 | 186 | |
3bb12056 SM |
187 | } |
188 | function disconnected(rfb, reason) { | |
189 | if (typeof(reason) !== 'undefined') { | |
190 | status(reason, "error"); | |
91308399 | 191 | } |
91308399 | 192 | } |
a7127fee | 193 | function notification(rfb, msg, level, options) { |
3bb12056 | 194 | status(msg, level); |
a7127fee | 195 | } |
91308399 | 196 | |
f8b399d7 | 197 | window.onresize = function () { |
198 | // When the window has been resized, wait until the size remains | |
199 | // the same for 0.5 seconds before sending the request for changing | |
200 | // the resolution of the session | |
201 | clearTimeout(resizeTimeout); | |
202 | resizeTimeout = setTimeout(function(){ | |
203 | UIresize(); | |
204 | }, 500); | |
205 | }; | |
206 | ||
fb35d50f MS |
207 | function xvpInit(ver) { |
208 | var xvpbuttons; | |
ae510306 | 209 | xvpbuttons = document.getElementById('noVNC_xvp_buttons'); |
fb35d50f MS |
210 | if (ver >= 1) { |
211 | xvpbuttons.style.display = 'inline'; | |
212 | } else { | |
213 | xvpbuttons.style.display = 'none'; | |
214 | } | |
215 | } | |
216 | ||
6f4b1e40 | 217 | window.onscriptsload = function () { |
9ebc84f2 | 218 | var host, port, password, path, token; |
91308399 | 219 | |
ae510306 SR |
220 | document.getElementById('sendCtrlAltDelButton').style.display = "inline"; |
221 | document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel; | |
222 | document.getElementById('xvpShutdownButton').onclick = xvpShutdown; | |
223 | document.getElementById('xvpRebootButton').onclick = xvpReboot; | |
224 | document.getElementById('xvpResetButton').onclick = xvpReset; | |
8db09746 | 225 | |
494b407a GV |
226 | WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn')); |
227 | document.title = unescape(WebUtil.getConfigVar('title', 'noVNC')); | |
bd96e919 | 228 | // By default, use the host and port of server that served this file |
494b407a GV |
229 | host = WebUtil.getConfigVar('host', window.location.hostname); |
230 | port = WebUtil.getConfigVar('port', window.location.port); | |
0139b256 | 231 | |
e83b9e03 WR |
232 | // if port == 80 (or 443) then it won't be present and should be |
233 | // set manually | |
234 | if (!port) { | |
82744aa8 | 235 | if (window.location.protocol.substring(0,5) == 'https') { |
e83b9e03 WR |
236 | port = 443; |
237 | } | |
82744aa8 | 238 | else if (window.location.protocol.substring(0,4) == 'http') { |
eb955f8c JD |
239 | port = 80; |
240 | } | |
e83b9e03 WR |
241 | } |
242 | ||
c55f05f6 MXPN |
243 | password = WebUtil.getConfigVar('password', ''); |
244 | path = WebUtil.getConfigVar('path', 'websockify'); | |
245 | ||
0139b256 AY |
246 | // If a token variable is passed in, set the parameter in a cookie. |
247 | // This is used by nova-novncproxy. | |
494b407a | 248 | token = WebUtil.getConfigVar('token', null); |
0139b256 | 249 | if (token) { |
c55f05f6 MXPN |
250 | |
251 | // if token is already present in the path we should use it | |
252 | path = WebUtil.injectParamIfMissing(path, "token", token); | |
253 | ||
0139b256 AY |
254 | WebUtil.createCookie('token', token, 1) |
255 | } | |
256 | ||
91308399 | 257 | if ((!host) || (!port)) { |
3bb12056 | 258 | status('Must specify host and port in URL', 'error'); |
91308399 JM |
259 | return; |
260 | } | |
261 | ||
d9fc1c7b | 262 | try { |
ae510306 | 263 | rfb = new RFB({'target': document.getElementById('noVNC_canvas'), |
494b407a | 264 | 'encrypt': WebUtil.getConfigVar('encrypt', |
d9fc1c7b | 265 | (window.location.protocol === "https:")), |
494b407a GV |
266 | 'repeaterID': WebUtil.getConfigVar('repeaterID', ''), |
267 | 'true_color': WebUtil.getConfigVar('true_color', true), | |
268 | 'local_cursor': WebUtil.getConfigVar('cursor', true), | |
269 | 'shared': WebUtil.getConfigVar('shared', true), | |
270 | 'view_only': WebUtil.getConfigVar('view_only', false), | |
3bb12056 | 271 | 'onNotification': notification, |
d9fc1c7b | 272 | 'onUpdateState': updateState, |
3bb12056 | 273 | 'onDisconnected': disconnected, |
d9fc1c7b SR |
274 | 'onXvpInit': xvpInit, |
275 | 'onPasswordRequired': passwordRequired, | |
3bb12056 SM |
276 | 'onFBUComplete': FBUComplete, |
277 | 'onDesktopName': updateDesktopName}); | |
d9fc1c7b | 278 | } catch (exc) { |
3bb12056 | 279 | status('Unable to create RFB client -- ' + exc, 'error'); |
d9fc1c7b SR |
280 | return; // don't continue trying to connect |
281 | } | |
282 | ||
9ebc84f2 | 283 | rfb.connect(host, port, password, path); |
8db09746 JM |
284 | }; |
285 | </script> | |
da6dd893 | 286 | |
8db09746 | 287 | </body> |
91308399 | 288 | </html> |