]>
Commit | Line | Data |
---|---|---|
40f281eb | 1 | <!DOCTYPE html> |
91308399 | 2 | <html> |
e84101b3 PÅ |
3 | <head> |
4 | ||
82744aa8 | 5 | <!-- |
83391ffc | 6 | noVNC example: lightweight example using minimal UI and features |
d58f8b51 | 7 | Copyright (C) 2012 Joel Martin |
178bf8ec | 8 | Copyright (C) 2017 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: | |
26586b9d | 13 | http://example.com/?host=HOST&port=PORT&encrypt=1 |
494b407a | 14 | or the fragment: |
26586b9d | 15 | http://example.com/#host=HOST&port=PORT&encrypt=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 | ||
7569cdc2 SR |
25 | <!-- Icons (see Makefile for what the sizes are for) --> |
26 | <link rel="icon" sizes="16x16" type="image/png" href="app/images/icons/novnc-16x16.png"> | |
27 | <link rel="icon" sizes="24x24" type="image/png" href="app/images/icons/novnc-24x24.png"> | |
28 | <link rel="icon" sizes="32x32" type="image/png" href="app/images/icons/novnc-32x32.png"> | |
29 | <link rel="icon" sizes="48x48" type="image/png" href="app/images/icons/novnc-48x48.png"> | |
30 | <link rel="icon" sizes="60x60" type="image/png" href="app/images/icons/novnc-60x60.png"> | |
31 | <link rel="icon" sizes="64x64" type="image/png" href="app/images/icons/novnc-64x64.png"> | |
32 | <link rel="icon" sizes="72x72" type="image/png" href="app/images/icons/novnc-72x72.png"> | |
33 | <link rel="icon" sizes="76x76" type="image/png" href="app/images/icons/novnc-76x76.png"> | |
34 | <link rel="icon" sizes="96x96" type="image/png" href="app/images/icons/novnc-96x96.png"> | |
35 | <link rel="icon" sizes="120x120" type="image/png" href="app/images/icons/novnc-120x120.png"> | |
36 | <link rel="icon" sizes="144x144" type="image/png" href="app/images/icons/novnc-144x144.png"> | |
37 | <link rel="icon" sizes="152x152" type="image/png" href="app/images/icons/novnc-152x152.png"> | |
38 | <link rel="icon" sizes="192x192" type="image/png" href="app/images/icons/novnc-192x192.png"> | |
39 | <link rel="icon" sizes="any" type="image/svg+xml" href="app/images/icons/novnc-icon.svg"> | |
40 | <!-- Repeated last so that legacy handling will pick this --> | |
41 | <link rel="icon" sizes="16x16" type="image/png" href="app/images/icons/novnc-16x16.png"> | |
42 | ||
33f5d3bd PÅ |
43 | <!-- Apple iOS Safari settings --> |
44 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
45 | <meta name="apple-mobile-web-app-capable" content="yes" /> | |
46 | <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> | |
7569cdc2 SR |
47 | <!-- Home Screen Icons (favourites and bookmarks use the normal icons) --> |
48 | <link rel="apple-touch-icon" sizes="60x60" type="image/png" href="app/images/icons/novnc-60x60.png"> | |
49 | <link rel="apple-touch-icon" sizes="76x76" type="image/png" href="app/images/icons/novnc-76x76.png"> | |
50 | <link rel="apple-touch-icon" sizes="120x120" type="image/png" href="app/images/icons/novnc-120x120.png"> | |
51 | <link rel="apple-touch-icon" sizes="152x152" type="image/png" href="app/images/icons/novnc-152x152.png"> | |
e84101b3 PÅ |
52 | |
53 | <!-- Stylesheets --> | |
83391ffc | 54 | <link rel="stylesheet" href="app/styles/lite.css"> |
e84101b3 PÅ |
55 | |
56 | <!-- | |
57 | <script type='text/javascript' | |
58 | src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> | |
59 | --> | |
8db09746 | 60 | |
7569cdc2 SR |
61 | <!-- promise polyfills promises for IE11 --> |
62 | <script src="vendor/promise.js"></script> | |
14ecdc62 FC |
63 | <!-- ES2015/ES6 modules polyfill --> |
64 | <script type="module"> | |
65 | window._noVNC_has_module_support = true; | |
66 | </script> | |
67 | <script> | |
68 | window.addEventListener("load", function() { | |
69 | if (window._noVNC_has_module_support) return; | |
70 | var loader = document.createElement("script"); | |
71 | loader.src = "vendor/browser-es-module-loader/dist/browser-es-module-loader.js"; | |
72 | document.head.appendChild(loader); | |
73 | }); | |
74 | </script> | |
75 | ||
76 | <!-- actual script modules --> | |
bf826444 | 77 | <script type="module" crossorigin="anonymous"> |
6f4b1e40 | 78 | // Load supporting scripts |
7569cdc2 SR |
79 | import * as WebUtil from './app/webutil.js'; |
80 | import RFB from './core/rfb.js'; | |
6f4b1e40 | 81 | |
8db09746 | 82 | var rfb; |
f8b399d7 | 83 | var resizeTimeout; |
3bb12056 | 84 | var desktopName; |
8db09746 | 85 | |
f8b399d7 | 86 | function UIresize() { |
494b407a | 87 | if (WebUtil.getConfigVar('resize', false)) { |
f8b399d7 | 88 | var innerW = window.innerWidth; |
89 | var innerH = window.innerHeight; | |
ae510306 | 90 | var controlbarH = document.getElementById('noVNC_status_bar').offsetHeight; |
f8b399d7 | 91 | if (innerW !== undefined && innerH !== undefined) |
67453ade | 92 | rfb.requestDesktopSize(innerW, innerH - controlbarH); |
f8b399d7 | 93 | } |
94 | } | |
95 | function FBUComplete(rfb, fbu) { | |
96 | UIresize(); | |
97 | rfb.set_onFBUComplete(function() { }); | |
98 | } | |
3bb12056 SM |
99 | function updateDesktopName(rfb, name) { |
100 | desktopName = name; | |
101 | } | |
7d714b15 SM |
102 | function passwordRequired(rfb, msg) { |
103 | if (typeof msg === 'undefined') { | |
104 | msg = 'Password Required: '; | |
105 | } | |
106 | var html; | |
c464f47e | 107 | |
7569cdc2 | 108 | var form = document.createElement('form'); |
cf3b5282 | 109 | form.innerHTML = '<label></label>'; |
8167e459 | 110 | form.innerHTML += '<input type=password size=10 id="password_input">'; |
7569cdc2 | 111 | form.onsubmit = setPassword; |
6048299a SR |
112 | |
113 | // bypass status() because it sets text content | |
114 | document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_warn"); | |
7569cdc2 SR |
115 | document.getElementById('noVNC_status').innerHTML = ''; |
116 | document.getElementById('noVNC_status').appendChild(form); | |
6048299a | 117 | document.getElementById('noVNC_status').querySelector('label').textContent = msg; |
d890e864 | 118 | } |
91308399 | 119 | function setPassword() { |
ae510306 | 120 | rfb.sendPassword(document.getElementById('password_input').value); |
91308399 JM |
121 | return false; |
122 | } | |
63708ff5 | 123 | function sendCtrlAltDel() { |
8db09746 | 124 | rfb.sendCtrlAltDel(); |
a8edf9d8 | 125 | return false; |
63708ff5 | 126 | } |
fb35d50f MS |
127 | function xvpShutdown() { |
128 | rfb.xvpShutdown(); | |
129 | return false; | |
130 | } | |
131 | function xvpReboot() { | |
132 | rfb.xvpReboot(); | |
133 | return false; | |
134 | } | |
135 | function xvpReset() { | |
136 | rfb.xvpReset(); | |
137 | return false; | |
138 | } | |
3bb12056 SM |
139 | function status(text, level) { |
140 | switch (level) { | |
141 | case 'normal': | |
142 | case 'warn': | |
143 | case 'error': | |
144 | break; | |
145 | default: | |
146 | level = "warn"; | |
147 | } | |
dc905e85 | 148 | document.getElementById('noVNC_status_bar').className = "noVNC_status_" + level; |
6048299a | 149 | document.getElementById('noVNC_status').textContent = text; |
3bb12056 SM |
150 | } |
151 | function updateState(rfb, state, oldstate) { | |
152 | var cad = document.getElementById('sendCtrlAltDelButton'); | |
91308399 | 153 | switch (state) { |
3bb12056 | 154 | case 'connecting': |
3cdc603a | 155 | status("Connecting", "normal"); |
3bb12056 SM |
156 | break; |
157 | case 'connected': | |
733d5009 | 158 | if (rfb && rfb.get_encrypt()) { |
3cdc603a | 159 | status("Connected (encrypted) to " + |
733d5009 SM |
160 | desktopName, "normal"); |
161 | } else { | |
3cdc603a | 162 | status("Connected (unencrypted) to " + |
733d5009 SM |
163 | desktopName, "normal"); |
164 | } | |
3bb12056 SM |
165 | break; |
166 | case 'disconnecting': | |
3cdc603a | 167 | status("Disconnecting", "normal"); |
3bb12056 SM |
168 | break; |
169 | case 'disconnected': | |
3cdc603a | 170 | status("Disconnected", "normal"); |
3bb12056 SM |
171 | break; |
172 | default: | |
173 | status(state, "warn"); | |
174 | break; | |
91308399 JM |
175 | } |
176 | ||
c2a4d3ef | 177 | if (state === 'connected') { |
fb35d50f MS |
178 | cad.disabled = false; |
179 | } else { | |
180 | cad.disabled = true; | |
181 | xvpInit(0); | |
182 | } | |
160fabf6 | 183 | |
3bb12056 SM |
184 | } |
185 | function disconnected(rfb, reason) { | |
186 | if (typeof(reason) !== 'undefined') { | |
187 | status(reason, "error"); | |
91308399 | 188 | } |
91308399 | 189 | } |
a7127fee | 190 | function notification(rfb, msg, level, options) { |
3bb12056 | 191 | status(msg, level); |
a7127fee | 192 | } |
91308399 | 193 | |
f8b399d7 | 194 | window.onresize = function () { |
195 | // When the window has been resized, wait until the size remains | |
196 | // the same for 0.5 seconds before sending the request for changing | |
197 | // the resolution of the session | |
198 | clearTimeout(resizeTimeout); | |
199 | resizeTimeout = setTimeout(function(){ | |
200 | UIresize(); | |
201 | }, 500); | |
202 | }; | |
203 | ||
fb35d50f MS |
204 | function xvpInit(ver) { |
205 | var xvpbuttons; | |
ae510306 | 206 | xvpbuttons = document.getElementById('noVNC_xvp_buttons'); |
fb35d50f | 207 | if (ver >= 1) { |
dc905e85 | 208 | xvpbuttons.className= "noVNC_shown"; |
fb35d50f | 209 | } else { |
dc905e85 | 210 | xvpbuttons.className = "noVNC_hidden"; |
fb35d50f MS |
211 | } |
212 | } | |
213 | ||
7569cdc2 SR |
214 | document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel; |
215 | document.getElementById('xvpShutdownButton').onclick = xvpShutdown; | |
216 | document.getElementById('xvpRebootButton').onclick = xvpReboot; | |
217 | document.getElementById('xvpResetButton').onclick = xvpReset; | |
91308399 | 218 | |
7569cdc2 | 219 | WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn')); |
08cd672e | 220 | document.title = WebUtil.getConfigVar('title', 'noVNC'); |
7569cdc2 SR |
221 | // By default, use the host and port of server that served this file |
222 | var host = WebUtil.getConfigVar('host', window.location.hostname); | |
223 | var port = WebUtil.getConfigVar('port', window.location.port); | |
8db09746 | 224 | |
7569cdc2 SR |
225 | // if port == 80 (or 443) then it won't be present and should be |
226 | // set manually | |
227 | if (!port) { | |
228 | if (window.location.protocol.substring(0,5) == 'https') { | |
229 | port = 443; | |
230 | } | |
231 | else if (window.location.protocol.substring(0,4) == 'http') { | |
232 | port = 80; | |
e83b9e03 | 233 | } |
7569cdc2 | 234 | } |
e83b9e03 | 235 | |
7569cdc2 SR |
236 | var password = WebUtil.getConfigVar('password', ''); |
237 | var path = WebUtil.getConfigVar('path', 'websockify'); | |
c55f05f6 | 238 | |
7569cdc2 SR |
239 | // If a token variable is passed in, set the parameter in a cookie. |
240 | // This is used by nova-novncproxy. | |
241 | var token = WebUtil.getConfigVar('token', null); | |
242 | if (token) { | |
243 | // if token is already present in the path we should use it | |
244 | path = WebUtil.injectParamIfMissing(path, "token", token); | |
c55f05f6 | 245 | |
7569cdc2 SR |
246 | WebUtil.createCookie('token', token, 1) |
247 | } | |
c55f05f6 | 248 | |
7569cdc2 | 249 | (function() { |
0139b256 | 250 | |
91308399 | 251 | if ((!host) || (!port)) { |
3bb12056 | 252 | status('Must specify host and port in URL', 'error'); |
91308399 JM |
253 | } |
254 | ||
d9fc1c7b | 255 | try { |
ae510306 | 256 | rfb = new RFB({'target': document.getElementById('noVNC_canvas'), |
494b407a | 257 | 'encrypt': WebUtil.getConfigVar('encrypt', |
d9fc1c7b | 258 | (window.location.protocol === "https:")), |
494b407a | 259 | 'repeaterID': WebUtil.getConfigVar('repeaterID', ''), |
494b407a GV |
260 | 'local_cursor': WebUtil.getConfigVar('cursor', true), |
261 | 'shared': WebUtil.getConfigVar('shared', true), | |
262 | 'view_only': WebUtil.getConfigVar('view_only', false), | |
3bb12056 | 263 | 'onNotification': notification, |
d9fc1c7b | 264 | 'onUpdateState': updateState, |
3bb12056 | 265 | 'onDisconnected': disconnected, |
d9fc1c7b SR |
266 | 'onXvpInit': xvpInit, |
267 | 'onPasswordRequired': passwordRequired, | |
3bb12056 SM |
268 | 'onFBUComplete': FBUComplete, |
269 | 'onDesktopName': updateDesktopName}); | |
d9fc1c7b | 270 | } catch (exc) { |
3bb12056 | 271 | status('Unable to create RFB client -- ' + exc, 'error'); |
d9fc1c7b SR |
272 | return; // don't continue trying to connect |
273 | } | |
274 | ||
9ebc84f2 | 275 | rfb.connect(host, port, password, path); |
7569cdc2 SR |
276 | })(); |
277 | </script> | |
278 | </head> | |
279 | ||
178bf8ec | 280 | <body> |
dc905e85 | 281 | <div id="noVNC_status_bar"> |
4023a6e1 SM |
282 | <div id="noVNC_left_dummy_elem"></div> |
283 | <div id="noVNC_status">Loading</div> | |
284 | <div id="noVNC_buttons"> | |
285 | <input type=button value="Send CtrlAltDel" | |
286 | id="sendCtrlAltDelButton" class="noVNC_shown"> | |
287 | <span id="noVNC_xvp_buttons" class="noVNC_hidden"> | |
288 | <input type=button value="Shutdown" | |
289 | id="xvpShutdownButton"> | |
290 | <input type=button value="Reboot" | |
291 | id="xvpRebootButton"> | |
292 | <input type=button value="Reset" | |
293 | id="xvpResetButton"> | |
294 | </span> | |
295 | </div> | |
178bf8ec SM |
296 | </div> |
297 | <canvas id="noVNC_canvas" width="0" height="0"> | |
298 | Canvas not supported. | |
299 | </canvas> | |
da6dd893 | 300 | |
178bf8ec | 301 | </body> |
91308399 | 302 | </html> |