]>
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"> | |
42463da1 | 39 | <!-- Firefox currently mishandles SVG, see #1419039 |
7569cdc2 | 40 | <link rel="icon" sizes="any" type="image/svg+xml" href="app/images/icons/novnc-icon.svg"> |
42463da1 | 41 | --> |
7569cdc2 SR |
42 | <!-- Repeated last so that legacy handling will pick this --> |
43 | <link rel="icon" sizes="16x16" type="image/png" href="app/images/icons/novnc-16x16.png"> | |
44 | ||
33f5d3bd PÅ |
45 | <!-- Apple iOS Safari settings --> |
46 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
47 | <meta name="apple-mobile-web-app-capable" content="yes" /> | |
48 | <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> | |
7569cdc2 SR |
49 | <!-- Home Screen Icons (favourites and bookmarks use the normal icons) --> |
50 | <link rel="apple-touch-icon" sizes="60x60" type="image/png" href="app/images/icons/novnc-60x60.png"> | |
51 | <link rel="apple-touch-icon" sizes="76x76" type="image/png" href="app/images/icons/novnc-76x76.png"> | |
52 | <link rel="apple-touch-icon" sizes="120x120" type="image/png" href="app/images/icons/novnc-120x120.png"> | |
53 | <link rel="apple-touch-icon" sizes="152x152" type="image/png" href="app/images/icons/novnc-152x152.png"> | |
e84101b3 PÅ |
54 | |
55 | <!-- Stylesheets --> | |
83391ffc | 56 | <link rel="stylesheet" href="app/styles/lite.css"> |
e84101b3 PÅ |
57 | |
58 | <!-- | |
59 | <script type='text/javascript' | |
60 | src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> | |
61 | --> | |
8db09746 | 62 | |
7569cdc2 SR |
63 | <!-- promise polyfills promises for IE11 --> |
64 | <script src="vendor/promise.js"></script> | |
14ecdc62 FC |
65 | <!-- ES2015/ES6 modules polyfill --> |
66 | <script type="module"> | |
67 | window._noVNC_has_module_support = true; | |
68 | </script> | |
69 | <script> | |
70 | window.addEventListener("load", function() { | |
71 | if (window._noVNC_has_module_support) return; | |
72 | var loader = document.createElement("script"); | |
73 | loader.src = "vendor/browser-es-module-loader/dist/browser-es-module-loader.js"; | |
74 | document.head.appendChild(loader); | |
75 | }); | |
76 | </script> | |
77 | ||
78 | <!-- actual script modules --> | |
bf826444 | 79 | <script type="module" crossorigin="anonymous"> |
6f4b1e40 | 80 | // Load supporting scripts |
7569cdc2 SR |
81 | import * as WebUtil from './app/webutil.js'; |
82 | import RFB from './core/rfb.js'; | |
6f4b1e40 | 83 | |
8db09746 | 84 | var rfb; |
3bb12056 | 85 | var desktopName; |
8db09746 | 86 | |
e89eef94 PO |
87 | function updateDesktopName(e) { |
88 | desktopName = e.detail.name; | |
3bb12056 | 89 | } |
e89eef94 | 90 | function credentials(e) { |
7d714b15 | 91 | var html; |
c464f47e | 92 | |
7569cdc2 | 93 | var form = document.createElement('form'); |
cf3b5282 | 94 | form.innerHTML = '<label></label>'; |
8167e459 | 95 | form.innerHTML += '<input type=password size=10 id="password_input">'; |
7569cdc2 | 96 | form.onsubmit = setPassword; |
6048299a SR |
97 | |
98 | // bypass status() because it sets text content | |
99 | document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_warn"); | |
7569cdc2 SR |
100 | document.getElementById('noVNC_status').innerHTML = ''; |
101 | document.getElementById('noVNC_status').appendChild(form); | |
430f00d6 | 102 | document.getElementById('noVNC_status').querySelector('label').textContent = 'Password Required: '; |
d890e864 | 103 | } |
91308399 | 104 | function setPassword() { |
430f00d6 | 105 | rfb.sendCredentials({ password: document.getElementById('password_input').value }); |
91308399 JM |
106 | return false; |
107 | } | |
63708ff5 | 108 | function sendCtrlAltDel() { |
8db09746 | 109 | rfb.sendCtrlAltDel(); |
a8edf9d8 | 110 | return false; |
63708ff5 | 111 | } |
cd523e8f PO |
112 | function machineShutdown() { |
113 | rfb.machineShutdown(); | |
fb35d50f MS |
114 | return false; |
115 | } | |
cd523e8f PO |
116 | function machineReboot() { |
117 | rfb.machineReboot(); | |
fb35d50f MS |
118 | return false; |
119 | } | |
cd523e8f PO |
120 | function machineReset() { |
121 | rfb.machineReset(); | |
fb35d50f MS |
122 | return false; |
123 | } | |
3bb12056 SM |
124 | function status(text, level) { |
125 | switch (level) { | |
126 | case 'normal': | |
127 | case 'warn': | |
128 | case 'error': | |
129 | break; | |
130 | default: | |
131 | level = "warn"; | |
132 | } | |
dc905e85 | 133 | document.getElementById('noVNC_status_bar').className = "noVNC_status_" + level; |
6048299a | 134 | document.getElementById('noVNC_status').textContent = text; |
3bb12056 | 135 | } |
91308399 | 136 | |
ee5cae9f SM |
137 | function connected(e) { |
138 | document.getElementById('sendCtrlAltDelButton').disabled = false; | |
ee5cae9f SM |
139 | if (WebUtil.getConfigVar('encrypt', |
140 | (window.location.protocol === "https:"))) { | |
141 | status("Connected (encrypted) to " + desktopName, "normal"); | |
fb35d50f | 142 | } else { |
ee5cae9f | 143 | status("Connected (unencrypted) to " + desktopName, "normal"); |
fb35d50f | 144 | } |
3bb12056 | 145 | } |
ee5cae9f SM |
146 | |
147 | function disconnected(e) { | |
148 | document.getElementById('sendCtrlAltDelButton').disabled = true; | |
149 | updatePowerButtons(); | |
d472f3f1 | 150 | if (e.detail.clean) { |
ee5cae9f | 151 | status("Disconnected", "normal"); |
d472f3f1 SM |
152 | } else { |
153 | status("Something went wrong, connection is closed", "error"); | |
91308399 | 154 | } |
91308399 JM |
155 | } |
156 | ||
cd523e8f PO |
157 | function updatePowerButtons() { |
158 | var powerbuttons; | |
159 | powerbuttons = document.getElementById('noVNC_power_buttons'); | |
747b4623 | 160 | if (rfb.capabilities.power) { |
56f21bf7 | 161 | powerbuttons.className= "noVNC_shown"; |
fb35d50f | 162 | } else { |
56f21bf7 | 163 | powerbuttons.className = "noVNC_hidden"; |
fb35d50f MS |
164 | } |
165 | } | |
166 | ||
7569cdc2 | 167 | document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel; |
cd523e8f PO |
168 | document.getElementById('machineShutdownButton').onclick = machineShutdown; |
169 | document.getElementById('machineRebootButton').onclick = machineReboot; | |
170 | document.getElementById('machineResetButton').onclick = machineReset; | |
91308399 | 171 | |
7569cdc2 | 172 | WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn')); |
08cd672e | 173 | document.title = WebUtil.getConfigVar('title', 'noVNC'); |
7569cdc2 SR |
174 | // By default, use the host and port of server that served this file |
175 | var host = WebUtil.getConfigVar('host', window.location.hostname); | |
176 | var port = WebUtil.getConfigVar('port', window.location.port); | |
8db09746 | 177 | |
7569cdc2 SR |
178 | // if port == 80 (or 443) then it won't be present and should be |
179 | // set manually | |
180 | if (!port) { | |
181 | if (window.location.protocol.substring(0,5) == 'https') { | |
182 | port = 443; | |
183 | } | |
184 | else if (window.location.protocol.substring(0,4) == 'http') { | |
185 | port = 80; | |
e83b9e03 | 186 | } |
7569cdc2 | 187 | } |
e83b9e03 | 188 | |
7569cdc2 SR |
189 | var password = WebUtil.getConfigVar('password', ''); |
190 | var path = WebUtil.getConfigVar('path', 'websockify'); | |
c55f05f6 | 191 | |
7569cdc2 SR |
192 | // If a token variable is passed in, set the parameter in a cookie. |
193 | // This is used by nova-novncproxy. | |
194 | var token = WebUtil.getConfigVar('token', null); | |
195 | if (token) { | |
196 | // if token is already present in the path we should use it | |
197 | path = WebUtil.injectParamIfMissing(path, "token", token); | |
c55f05f6 | 198 | |
7569cdc2 SR |
199 | WebUtil.createCookie('token', token, 1) |
200 | } | |
c55f05f6 | 201 | |
7569cdc2 | 202 | (function() { |
0139b256 | 203 | |
ee5cae9f SM |
204 | status("Connecting", "normal"); |
205 | ||
91308399 | 206 | if ((!host) || (!port)) { |
3bb12056 | 207 | status('Must specify host and port in URL', 'error'); |
91308399 JM |
208 | } |
209 | ||
5b4e5d01 PO |
210 | var url; |
211 | ||
212 | if (WebUtil.getConfigVar('encrypt', | |
213 | (window.location.protocol === "https:"))) { | |
214 | url = 'wss'; | |
215 | } else { | |
216 | url = 'ws'; | |
217 | } | |
218 | ||
219 | url += '://' + host; | |
220 | if(port) { | |
221 | url += ':' + port; | |
d9fc1c7b | 222 | } |
5b4e5d01 | 223 | url += '/' + path; |
d9fc1c7b | 224 | |
9b84f516 | 225 | rfb = new RFB(document.body, url, |
2f4516f2 PO |
226 | { repeaterID: WebUtil.getConfigVar('repeaterID', ''), |
227 | shared: WebUtil.getConfigVar('shared', true), | |
228 | credentials: { password: password } }); | |
5b20d338 | 229 | rfb.viewOnly = WebUtil.getConfigVar('view_only', false); |
ee5cae9f SM |
230 | rfb.addEventListener("connect", connected); |
231 | rfb.addEventListener("disconnect", disconnected); | |
9b84f516 | 232 | rfb.addEventListener("capabilities", function () { updatePowerButtons(); }); |
e89eef94 PO |
233 | rfb.addEventListener("credentialsrequired", credentials); |
234 | rfb.addEventListener("desktopname", updateDesktopName); | |
bd2ce0ca | 235 | rfb.scaleViewport = WebUtil.getConfigVar('scale', false); |
9b84f516 | 236 | rfb.resizeSession = WebUtil.getConfigVar('resize', false); |
7569cdc2 SR |
237 | })(); |
238 | </script> | |
239 | </head> | |
240 | ||
178bf8ec | 241 | <body> |
dc905e85 | 242 | <div id="noVNC_status_bar"> |
4023a6e1 SM |
243 | <div id="noVNC_left_dummy_elem"></div> |
244 | <div id="noVNC_status">Loading</div> | |
245 | <div id="noVNC_buttons"> | |
246 | <input type=button value="Send CtrlAltDel" | |
247 | id="sendCtrlAltDelButton" class="noVNC_shown"> | |
a201bfc5 | 248 | <span id="noVNC_power_buttons" class="noVNC_hidden"> |
4023a6e1 | 249 | <input type=button value="Shutdown" |
a201bfc5 | 250 | id="machineShutdownButton"> |
4023a6e1 | 251 | <input type=button value="Reboot" |
a201bfc5 | 252 | id="machineRebootButton"> |
4023a6e1 | 253 | <input type=button value="Reset" |
a201bfc5 | 254 | id="machineResetButton"> |
4023a6e1 SM |
255 | </span> |
256 | </div> | |
178bf8ec | 257 | </div> |
178bf8ec | 258 | </body> |
91308399 | 259 | </html> |