]>
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 | |
14 | --> | |
e84101b3 PÅ |
15 | <title>noVNC</title> |
16 | ||
33f5d3bd PÅ |
17 | <meta charset="utf-8"> |
18 | ||
e84101b3 PÅ |
19 | <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame |
20 | Remove this if you use the .htaccess --> | |
33f5d3bd PÅ |
21 | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
22 | ||
23 | <!-- Apple iOS Safari settings --> | |
24 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
25 | <meta name="apple-mobile-web-app-capable" content="yes" /> | |
26 | <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> | |
27 | <!-- App Start Icon --> | |
28 | <link rel="apple-touch-startup-image" href="images/screen_320x460.png" /> | |
29 | <!-- For iOS devices set the icon to use if user bookmarks app on their homescreen --> | |
30 | <link rel="apple-touch-icon" href="images/screen_57x57.png"> | |
31 | <!-- | |
32 | <link rel="apple-touch-icon-precomposed" href="images/screen_57x57.png" /> | |
33 | --> | |
e84101b3 PÅ |
34 | |
35 | ||
36 | <!-- Stylesheets --> | |
37 | <link rel="stylesheet" href="include/base.css" title="plain"> | |
38 | ||
39 | <!-- | |
40 | <script type='text/javascript' | |
41 | src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> | |
42 | --> | |
6f4b1e40 | 43 | <script src="include/util.js"></script> |
e84101b3 | 44 | </head> |
91308399 | 45 | |
e84101b3 PÅ |
46 | <body style="margin: 0px;"> |
47 | <div id="noVNC_screen"> | |
a7f55899 | 48 | <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;"> |
8db09746 | 49 | <table border=0 width="100%"><tr> |
35b29c98 | 50 | <td><div id="noVNC_status" style="position: relative; height: auto;"> |
51 | Loading | |
52 | </div></td> | |
a7f55899 | 53 | <td width="1%"><div id="noVNC_buttons"> |
63708ff5 | 54 | <input type=button value="Send CtrlAltDel" |
8db09746 | 55 | id="sendCtrlAltDelButton"> |
fb35d50f MS |
56 | <span id="noVNC_xvp_buttons"> |
57 | <input type=button value="Shutdown" | |
58 | id="xvpShutdownButton"> | |
59 | <input type=button value="Reboot" | |
60 | id="xvpRebootButton"> | |
61 | <input type=button value="Reset" | |
62 | id="xvpResetButton"> | |
63 | </span> | |
8db09746 | 64 | </div></td> |
63708ff5 JM |
65 | </tr></table> |
66 | </div> | |
a7f55899 | 67 | <canvas id="noVNC_canvas" width="640px" height="20px"> |
91308399 JM |
68 | Canvas not supported. |
69 | </canvas> | |
70 | </div> | |
91308399 | 71 | |
8db09746 JM |
72 | <script> |
73 | /*jslint white: false */ | |
74 | /*global window, $, Util, RFB, */ | |
75 | "use strict"; | |
76 | ||
6f4b1e40 JM |
77 | // Load supporting scripts |
78 | Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js", | |
2ea40fdf | 79 | "keysymdef.js", "keyboard.js", "input.js", "display.js", |
03314953 | 80 | "jsunzip.js", "rfb.js", "keysym.js"]); |
6f4b1e40 | 81 | |
8db09746 | 82 | var rfb; |
f8b399d7 | 83 | var resizeTimeout; |
8db09746 | 84 | |
f8b399d7 | 85 | |
86 | function UIresize() { | |
87 | if (WebUtil.getQueryVar('resize', false)) { | |
88 | var innerW = window.innerWidth; | |
89 | var innerH = window.innerHeight; | |
90 | var controlbarH = $D('noVNC_status_bar').offsetHeight; | |
91 | var padding = 5; | |
92 | if (innerW !== undefined && innerH !== undefined) | |
93 | rfb.setDesktopSize(innerW, innerH - controlbarH - padding); | |
94 | } | |
95 | } | |
96 | function FBUComplete(rfb, fbu) { | |
97 | UIresize(); | |
98 | rfb.set_onFBUComplete(function() { }); | |
99 | } | |
d890e864 JM |
100 | function passwordRequired(rfb) { |
101 | var msg; | |
102 | msg = '<form onsubmit="return setPassword();"'; | |
103 | msg += ' style="margin-bottom: 0px">'; | |
104 | msg += 'Password Required: '; | |
a7f55899 | 105 | msg += '<input type=password size=10 id="password_input" class="noVNC_status">'; |
d890e864 | 106 | msg += '<\/form>'; |
a7f55899 JM |
107 | $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn"); |
108 | $D('noVNC_status').innerHTML = msg; | |
d890e864 | 109 | } |
91308399 | 110 | function setPassword() { |
e4671910 | 111 | rfb.sendPassword($D('password_input').value); |
91308399 JM |
112 | return false; |
113 | } | |
63708ff5 | 114 | function sendCtrlAltDel() { |
8db09746 | 115 | rfb.sendCtrlAltDel(); |
a8edf9d8 | 116 | return false; |
63708ff5 | 117 | } |
fb35d50f MS |
118 | function xvpShutdown() { |
119 | rfb.xvpShutdown(); | |
120 | return false; | |
121 | } | |
122 | function xvpReboot() { | |
123 | rfb.xvpReboot(); | |
124 | return false; | |
125 | } | |
126 | function xvpReset() { | |
127 | rfb.xvpReset(); | |
128 | return false; | |
129 | } | |
8db09746 | 130 | function updateState(rfb, state, oldstate, msg) { |
d890e864 | 131 | var s, sb, cad, level; |
a7f55899 JM |
132 | s = $D('noVNC_status'); |
133 | sb = $D('noVNC_status_bar'); | |
e4671910 | 134 | cad = $D('sendCtrlAltDelButton'); |
91308399 | 135 | switch (state) { |
d890e864 JM |
136 | case 'failed': level = "error"; break; |
137 | case 'fatal': level = "error"; break; | |
138 | case 'normal': level = "normal"; break; | |
139 | case 'disconnected': level = "normal"; break; | |
140 | case 'loaded': level = "normal"; break; | |
141 | default: level = "warn"; break; | |
91308399 JM |
142 | } |
143 | ||
fb35d50f MS |
144 | if (state === "normal") { |
145 | cad.disabled = false; | |
146 | } else { | |
147 | cad.disabled = true; | |
148 | xvpInit(0); | |
149 | } | |
160fabf6 | 150 | |
91308399 | 151 | if (typeof(msg) !== 'undefined') { |
a7f55899 | 152 | sb.setAttribute("class", "noVNC_status_" + level); |
91308399 JM |
153 | s.innerHTML = msg; |
154 | } | |
91308399 JM |
155 | } |
156 | ||
f8b399d7 | 157 | window.onresize = function () { |
158 | // When the window has been resized, wait until the size remains | |
159 | // the same for 0.5 seconds before sending the request for changing | |
160 | // the resolution of the session | |
161 | clearTimeout(resizeTimeout); | |
162 | resizeTimeout = setTimeout(function(){ | |
163 | UIresize(); | |
164 | }, 500); | |
165 | }; | |
166 | ||
fb35d50f MS |
167 | function xvpInit(ver) { |
168 | var xvpbuttons; | |
169 | xvpbuttons = $D('noVNC_xvp_buttons'); | |
170 | if (ver >= 1) { | |
171 | xvpbuttons.style.display = 'inline'; | |
172 | } else { | |
173 | xvpbuttons.style.display = 'none'; | |
174 | } | |
175 | } | |
176 | ||
6f4b1e40 | 177 | window.onscriptsload = function () { |
9ebc84f2 | 178 | var host, port, password, path, token; |
91308399 | 179 | |
a7f55899 | 180 | $D('sendCtrlAltDelButton').style.display = "inline"; |
e4671910 | 181 | $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; |
fb35d50f MS |
182 | $D('xvpShutdownButton').onclick = xvpShutdown; |
183 | $D('xvpRebootButton').onclick = xvpReboot; | |
184 | $D('xvpResetButton').onclick = xvpReset; | |
8db09746 | 185 | |
2cde6e43 | 186 | WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn')); |
2270c7b5 | 187 | document.title = unescape(WebUtil.getQueryVar('title', 'noVNC')); |
bd96e919 JM |
188 | // By default, use the host and port of server that served this file |
189 | host = WebUtil.getQueryVar('host', window.location.hostname); | |
190 | port = WebUtil.getQueryVar('port', window.location.port); | |
0139b256 | 191 | |
e83b9e03 WR |
192 | // if port == 80 (or 443) then it won't be present and should be |
193 | // set manually | |
194 | if (!port) { | |
82744aa8 | 195 | if (window.location.protocol.substring(0,5) == 'https') { |
e83b9e03 WR |
196 | port = 443; |
197 | } | |
82744aa8 | 198 | else if (window.location.protocol.substring(0,4) == 'http') { |
eb955f8c JD |
199 | port = 80; |
200 | } | |
e83b9e03 WR |
201 | } |
202 | ||
0139b256 AY |
203 | // If a token variable is passed in, set the parameter in a cookie. |
204 | // This is used by nova-novncproxy. | |
4c75210a | 205 | token = WebUtil.getQueryVar('token', null); |
0139b256 | 206 | if (token) { |
0139b256 AY |
207 | WebUtil.createCookie('token', token, 1) |
208 | } | |
209 | ||
8d5d2c82 | 210 | password = WebUtil.getQueryVar('password', ''); |
523cc4d6 | 211 | path = WebUtil.getQueryVar('path', 'websockify'); |
b50f3406 | 212 | |
91308399 JM |
213 | if ((!host) || (!port)) { |
214 | updateState('failed', | |
215 | "Must specify host and port in URL"); | |
216 | return; | |
217 | } | |
218 | ||
a7f55899 | 219 | rfb = new RFB({'target': $D('noVNC_canvas'), |
1af3e54b JM |
220 | 'encrypt': WebUtil.getQueryVar('encrypt', |
221 | (window.location.protocol === "https:")), | |
9ebc84f2 | 222 | 'repeaterID': WebUtil.getQueryVar('repeaterID', ''), |
f1a9971c JM |
223 | 'true_color': WebUtil.getQueryVar('true_color', true), |
224 | 'local_cursor': WebUtil.getQueryVar('cursor', true), | |
225 | 'shared': WebUtil.getQueryVar('shared', true), | |
06a9ef0c | 226 | 'view_only': WebUtil.getQueryVar('view_only', false), |
77bd04f8 | 227 | 'onUpdateState': updateState, |
fb35d50f | 228 | 'onXvpInit': xvpInit, |
f8b399d7 | 229 | 'onPasswordRequired': passwordRequired, |
230 | 'onFBUComplete': FBUComplete}); | |
9ebc84f2 | 231 | rfb.connect(host, port, password, path); |
8db09746 JM |
232 | }; |
233 | </script> | |
da6dd893 | 234 | |
8db09746 | 235 | </body> |
91308399 | 236 | </html> |