]>
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 --> | |
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 | --> | |
e84101b3 PÅ |
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 | --> | |
6f4b1e40 | 45 | <script src="include/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 JM |
79 | // Load supporting scripts |
80 | Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js", | |
2ea40fdf | 81 | "keysymdef.js", "keyboard.js", "input.js", "display.js", |
6940936f | 82 | "inflator.js", "rfb.js", "keysym.js"]); |
6f4b1e40 | 83 | |
8db09746 | 84 | var rfb; |
f8b399d7 | 85 | var resizeTimeout; |
8db09746 | 86 | |
f8b399d7 | 87 | |
88 | function UIresize() { | |
494b407a | 89 | if (WebUtil.getConfigVar('resize', false)) { |
f8b399d7 | 90 | var innerW = window.innerWidth; |
91 | var innerH = window.innerHeight; | |
92 | var controlbarH = $D('noVNC_status_bar').offsetHeight; | |
93 | var padding = 5; | |
94 | if (innerW !== undefined && innerH !== undefined) | |
ae116051 | 95 | rfb.requestDesktopSize(innerW, innerH - controlbarH - padding); |
f8b399d7 | 96 | } |
97 | } | |
98 | function FBUComplete(rfb, fbu) { | |
99 | UIresize(); | |
100 | rfb.set_onFBUComplete(function() { }); | |
101 | } | |
d890e864 JM |
102 | function passwordRequired(rfb) { |
103 | var msg; | |
104 | msg = '<form onsubmit="return setPassword();"'; | |
105 | msg += ' style="margin-bottom: 0px">'; | |
106 | msg += 'Password Required: '; | |
a7f55899 | 107 | msg += '<input type=password size=10 id="password_input" class="noVNC_status">'; |
d890e864 | 108 | msg += '<\/form>'; |
a7f55899 JM |
109 | $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn"); |
110 | $D('noVNC_status').innerHTML = msg; | |
d890e864 | 111 | } |
91308399 | 112 | function setPassword() { |
e4671910 | 113 | rfb.sendPassword($D('password_input').value); |
91308399 JM |
114 | return false; |
115 | } | |
63708ff5 | 116 | function sendCtrlAltDel() { |
8db09746 | 117 | rfb.sendCtrlAltDel(); |
a8edf9d8 | 118 | return false; |
63708ff5 | 119 | } |
fb35d50f MS |
120 | function xvpShutdown() { |
121 | rfb.xvpShutdown(); | |
122 | return false; | |
123 | } | |
124 | function xvpReboot() { | |
125 | rfb.xvpReboot(); | |
126 | return false; | |
127 | } | |
128 | function xvpReset() { | |
129 | rfb.xvpReset(); | |
130 | return false; | |
131 | } | |
8db09746 | 132 | function updateState(rfb, state, oldstate, msg) { |
d890e864 | 133 | var s, sb, cad, level; |
a7f55899 JM |
134 | s = $D('noVNC_status'); |
135 | sb = $D('noVNC_status_bar'); | |
e4671910 | 136 | cad = $D('sendCtrlAltDelButton'); |
91308399 | 137 | switch (state) { |
d890e864 JM |
138 | case 'failed': level = "error"; break; |
139 | case 'fatal': level = "error"; break; | |
140 | case 'normal': level = "normal"; break; | |
141 | case 'disconnected': level = "normal"; break; | |
142 | case 'loaded': level = "normal"; break; | |
143 | default: level = "warn"; break; | |
91308399 JM |
144 | } |
145 | ||
fb35d50f MS |
146 | if (state === "normal") { |
147 | cad.disabled = false; | |
148 | } else { | |
149 | cad.disabled = true; | |
150 | xvpInit(0); | |
151 | } | |
160fabf6 | 152 | |
91308399 | 153 | if (typeof(msg) !== 'undefined') { |
a7f55899 | 154 | sb.setAttribute("class", "noVNC_status_" + level); |
91308399 JM |
155 | s.innerHTML = msg; |
156 | } | |
91308399 JM |
157 | } |
158 | ||
f8b399d7 | 159 | window.onresize = function () { |
160 | // When the window has been resized, wait until the size remains | |
161 | // the same for 0.5 seconds before sending the request for changing | |
162 | // the resolution of the session | |
163 | clearTimeout(resizeTimeout); | |
164 | resizeTimeout = setTimeout(function(){ | |
165 | UIresize(); | |
166 | }, 500); | |
167 | }; | |
168 | ||
fb35d50f MS |
169 | function xvpInit(ver) { |
170 | var xvpbuttons; | |
171 | xvpbuttons = $D('noVNC_xvp_buttons'); | |
172 | if (ver >= 1) { | |
173 | xvpbuttons.style.display = 'inline'; | |
174 | } else { | |
175 | xvpbuttons.style.display = 'none'; | |
176 | } | |
177 | } | |
178 | ||
6f4b1e40 | 179 | window.onscriptsload = function () { |
9ebc84f2 | 180 | var host, port, password, path, token; |
91308399 | 181 | |
a7f55899 | 182 | $D('sendCtrlAltDelButton').style.display = "inline"; |
e4671910 | 183 | $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; |
fb35d50f MS |
184 | $D('xvpShutdownButton').onclick = xvpShutdown; |
185 | $D('xvpRebootButton').onclick = xvpReboot; | |
186 | $D('xvpResetButton').onclick = xvpReset; | |
8db09746 | 187 | |
494b407a GV |
188 | WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn')); |
189 | document.title = unescape(WebUtil.getConfigVar('title', 'noVNC')); | |
bd96e919 | 190 | // By default, use the host and port of server that served this file |
494b407a GV |
191 | host = WebUtil.getConfigVar('host', window.location.hostname); |
192 | port = WebUtil.getConfigVar('port', window.location.port); | |
0139b256 | 193 | |
e83b9e03 WR |
194 | // if port == 80 (or 443) then it won't be present and should be |
195 | // set manually | |
196 | if (!port) { | |
82744aa8 | 197 | if (window.location.protocol.substring(0,5) == 'https') { |
e83b9e03 WR |
198 | port = 443; |
199 | } | |
82744aa8 | 200 | else if (window.location.protocol.substring(0,4) == 'http') { |
eb955f8c JD |
201 | port = 80; |
202 | } | |
e83b9e03 WR |
203 | } |
204 | ||
c55f05f6 MXPN |
205 | password = WebUtil.getConfigVar('password', ''); |
206 | path = WebUtil.getConfigVar('path', 'websockify'); | |
207 | ||
0139b256 AY |
208 | // If a token variable is passed in, set the parameter in a cookie. |
209 | // This is used by nova-novncproxy. | |
494b407a | 210 | token = WebUtil.getConfigVar('token', null); |
0139b256 | 211 | if (token) { |
c55f05f6 MXPN |
212 | |
213 | // if token is already present in the path we should use it | |
214 | path = WebUtil.injectParamIfMissing(path, "token", token); | |
215 | ||
0139b256 AY |
216 | WebUtil.createCookie('token', token, 1) |
217 | } | |
218 | ||
91308399 | 219 | if ((!host) || (!port)) { |
2bcfd586 | 220 | updateState(null, 'fatal', null, 'Must specify host and port in URL'); |
91308399 JM |
221 | return; |
222 | } | |
223 | ||
d9fc1c7b SR |
224 | try { |
225 | rfb = new RFB({'target': $D('noVNC_canvas'), | |
494b407a | 226 | 'encrypt': WebUtil.getConfigVar('encrypt', |
d9fc1c7b | 227 | (window.location.protocol === "https:")), |
494b407a GV |
228 | 'repeaterID': WebUtil.getConfigVar('repeaterID', ''), |
229 | 'true_color': WebUtil.getConfigVar('true_color', true), | |
230 | 'local_cursor': WebUtil.getConfigVar('cursor', true), | |
231 | 'shared': WebUtil.getConfigVar('shared', true), | |
232 | 'view_only': WebUtil.getConfigVar('view_only', false), | |
d9fc1c7b SR |
233 | 'onUpdateState': updateState, |
234 | 'onXvpInit': xvpInit, | |
235 | 'onPasswordRequired': passwordRequired, | |
236 | 'onFBUComplete': FBUComplete}); | |
237 | } catch (exc) { | |
2bcfd586 | 238 | updateState(null, 'fatal', null, 'Unable to create RFB client -- ' + exc); |
d9fc1c7b SR |
239 | return; // don't continue trying to connect |
240 | } | |
241 | ||
9ebc84f2 | 242 | rfb.connect(host, port, password, path); |
8db09746 JM |
243 | }; |
244 | </script> | |
da6dd893 | 245 | |
8db09746 | 246 | </body> |
91308399 | 247 | </html> |