]> git.proxmox.com Git - mirror_novnc.git/blob - vnc_lite.html
Add Chinese (Traditional) translation
[mirror_novnc.git] / vnc_lite.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4
5 <!--
6 noVNC example: lightweight example using minimal UI and features
7 Copyright (C) 2012 Joel Martin
8 Copyright (C) 2017 Samuel Mannehed for Cendio AB
9 noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
10 This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
11
12 Connect parameters are provided in query string:
13 http://example.com/?host=HOST&port=PORT&encrypt=1
14 or the fragment:
15 http://example.com/#host=HOST&port=PORT&encrypt=1
16 -->
17 <title>noVNC</title>
18
19 <meta charset="utf-8">
20
21 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
22 Remove this if you use the .htaccess -->
23 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
24
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
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" />
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">
52
53 <!-- Stylesheets -->
54 <link rel="stylesheet" href="app/styles/lite.css">
55
56 <!--
57 <script type='text/javascript'
58 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
59 -->
60
61 <!-- promise polyfills promises for IE11 -->
62 <script src="vendor/promise.js"></script>
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 -->
77 <script type="module" crossorigin="anonymous">
78 // Load supporting scripts
79 import * as WebUtil from './app/webutil.js';
80 import RFB from './core/rfb.js';
81
82 var rfb;
83 var desktopName;
84
85 function updateDesktopName(e) {
86 desktopName = e.detail.name;
87 }
88 function credentials(e) {
89 var html;
90
91 var form = document.createElement('form');
92 form.innerHTML = '<label></label>';
93 form.innerHTML += '<input type=password size=10 id="password_input">';
94 form.onsubmit = setPassword;
95
96 // bypass status() because it sets text content
97 document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
98 document.getElementById('noVNC_status').innerHTML = '';
99 document.getElementById('noVNC_status').appendChild(form);
100 document.getElementById('noVNC_status').querySelector('label').textContent = 'Password Required: ';
101 }
102 function setPassword() {
103 rfb.sendCredentials({ password: document.getElementById('password_input').value });
104 return false;
105 }
106 function sendCtrlAltDel() {
107 rfb.sendCtrlAltDel();
108 return false;
109 }
110 function machineShutdown() {
111 rfb.machineShutdown();
112 return false;
113 }
114 function machineReboot() {
115 rfb.machineReboot();
116 return false;
117 }
118 function machineReset() {
119 rfb.machineReset();
120 return false;
121 }
122 function status(text, level) {
123 switch (level) {
124 case 'normal':
125 case 'warn':
126 case 'error':
127 break;
128 default:
129 level = "warn";
130 }
131 document.getElementById('noVNC_status_bar').className = "noVNC_status_" + level;
132 document.getElementById('noVNC_status').textContent = text;
133 }
134
135 function connected(e) {
136 document.getElementById('sendCtrlAltDelButton').disabled = false;
137 if (WebUtil.getConfigVar('encrypt',
138 (window.location.protocol === "https:"))) {
139 status("Connected (encrypted) to " + desktopName, "normal");
140 } else {
141 status("Connected (unencrypted) to " + desktopName, "normal");
142 }
143 }
144
145 function disconnected(e) {
146 document.getElementById('sendCtrlAltDelButton').disabled = true;
147 updatePowerButtons();
148 if (e.detail.clean) {
149 status("Disconnected", "normal");
150 } else {
151 status("Something went wrong, connection is closed", "error");
152 }
153 }
154
155 function updatePowerButtons() {
156 var powerbuttons;
157 powerbuttons = document.getElementById('noVNC_power_buttons');
158 if (rfb.capabilities.power) {
159 powerbuttons.className= "noVNC_shown";
160 } else {
161 powerbuttons.className = "noVNC_hidden";
162 }
163 }
164
165 document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
166 document.getElementById('machineShutdownButton').onclick = machineShutdown;
167 document.getElementById('machineRebootButton').onclick = machineReboot;
168 document.getElementById('machineResetButton').onclick = machineReset;
169
170 WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn'));
171 document.title = WebUtil.getConfigVar('title', 'noVNC');
172 // By default, use the host and port of server that served this file
173 var host = WebUtil.getConfigVar('host', window.location.hostname);
174 var port = WebUtil.getConfigVar('port', window.location.port);
175
176 // if port == 80 (or 443) then it won't be present and should be
177 // set manually
178 if (!port) {
179 if (window.location.protocol.substring(0,5) == 'https') {
180 port = 443;
181 }
182 else if (window.location.protocol.substring(0,4) == 'http') {
183 port = 80;
184 }
185 }
186
187 var password = WebUtil.getConfigVar('password', '');
188 var path = WebUtil.getConfigVar('path', 'websockify');
189
190 // If a token variable is passed in, set the parameter in a cookie.
191 // This is used by nova-novncproxy.
192 var token = WebUtil.getConfigVar('token', null);
193 if (token) {
194 // if token is already present in the path we should use it
195 path = WebUtil.injectParamIfMissing(path, "token", token);
196
197 WebUtil.createCookie('token', token, 1)
198 }
199
200 (function() {
201
202 status("Connecting", "normal");
203
204 if ((!host) || (!port)) {
205 status('Must specify host and port in URL', 'error');
206 }
207
208 var url;
209
210 if (WebUtil.getConfigVar('encrypt',
211 (window.location.protocol === "https:"))) {
212 url = 'wss';
213 } else {
214 url = 'ws';
215 }
216
217 url += '://' + host;
218 if(port) {
219 url += ':' + port;
220 }
221 url += '/' + path;
222
223 rfb = new RFB(document.body, url,
224 { repeaterID: WebUtil.getConfigVar('repeaterID', ''),
225 shared: WebUtil.getConfigVar('shared', true),
226 credentials: { password: password } });
227 rfb.viewOnly = WebUtil.getConfigVar('view_only', false);
228 rfb.addEventListener("connect", connected);
229 rfb.addEventListener("disconnect", disconnected);
230 rfb.addEventListener("capabilities", function () { updatePowerButtons(); });
231 rfb.addEventListener("credentialsrequired", credentials);
232 rfb.addEventListener("desktopname", updateDesktopName);
233 rfb.scaleViewport = WebUtil.getConfigVar('scale', false);
234 rfb.resizeSession = WebUtil.getConfigVar('resize', false);
235 })();
236 </script>
237 </head>
238
239 <body>
240 <div id="noVNC_status_bar">
241 <div id="noVNC_left_dummy_elem"></div>
242 <div id="noVNC_status">Loading</div>
243 <div id="noVNC_buttons">
244 <input type=button value="Send CtrlAltDel"
245 id="sendCtrlAltDelButton" class="noVNC_shown">
246 <span id="noVNC_power_buttons" class="noVNC_hidden">
247 <input type=button value="Shutdown"
248 id="machineShutdownButton">
249 <input type=button value="Reboot"
250 id="machineRebootButton">
251 <input type=button value="Reset"
252 id="machineResetButton">
253 </span>
254 </div>
255 </div>
256 </body>
257 </html>