]> git.proxmox.com Git - mirror_novnc.git/blob - vnc_lite.html
Remove iOS specific code from vnc_lite
[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) 2018 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 app/images/icons/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 <!-- Firefox currently mishandles SVG, see #1419039
40 <link rel="icon" sizes="any" type="image/svg+xml" href="app/images/icons/novnc-icon.svg">
41 -->
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
45 <!-- Stylesheets -->
46 <link rel="stylesheet" href="app/styles/lite.css">
47
48 <!-- promise polyfills promises for IE11 -->
49 <script src="vendor/promise.js"></script>
50 <!-- ES2015/ES6 modules polyfill -->
51 <script type="module">
52 window._noVNC_has_module_support = true;
53 </script>
54 <script>
55 window.addEventListener("load", function() {
56 if (window._noVNC_has_module_support) return;
57 var loader = document.createElement("script");
58 loader.src = "vendor/browser-es-module-loader/dist/browser-es-module-loader.js";
59 document.head.appendChild(loader);
60 });
61 </script>
62
63 <!-- actual script modules -->
64 <script type="module" crossorigin="anonymous">
65 // Load supporting scripts
66 import * as WebUtil from './app/webutil.js';
67 import RFB from './core/rfb.js';
68
69 var rfb;
70 var desktopName;
71
72 function updateDesktopName(e) {
73 desktopName = e.detail.name;
74 }
75 function credentials(e) {
76 var html;
77
78 var form = document.createElement('form');
79 form.innerHTML = '<label></label>';
80 form.innerHTML += '<input type=password size=10 id="password_input">';
81 form.onsubmit = setPassword;
82
83 // bypass status() because it sets text content
84 document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
85 document.getElementById('noVNC_status').innerHTML = '';
86 document.getElementById('noVNC_status').appendChild(form);
87 document.getElementById('noVNC_status').querySelector('label').textContent = 'Password Required: ';
88 }
89 function setPassword() {
90 rfb.sendCredentials({ password: document.getElementById('password_input').value });
91 return false;
92 }
93 function sendCtrlAltDel() {
94 rfb.sendCtrlAltDel();
95 return false;
96 }
97 function status(text, level) {
98 switch (level) {
99 case 'normal':
100 case 'warn':
101 case 'error':
102 break;
103 default:
104 level = "warn";
105 }
106 document.getElementById('noVNC_status_bar').className = "noVNC_status_" + level;
107 document.getElementById('noVNC_status').textContent = text;
108 }
109
110 function connected(e) {
111 document.getElementById('sendCtrlAltDelButton').disabled = false;
112 if (WebUtil.getConfigVar('encrypt',
113 (window.location.protocol === "https:"))) {
114 status("Connected (encrypted) to " + desktopName, "normal");
115 } else {
116 status("Connected (unencrypted) to " + desktopName, "normal");
117 }
118 }
119
120 function disconnected(e) {
121 document.getElementById('sendCtrlAltDelButton').disabled = true;
122 if (e.detail.clean) {
123 status("Disconnected", "normal");
124 } else {
125 status("Something went wrong, connection is closed", "error");
126 }
127 }
128
129 document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
130
131 WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn'));
132 document.title = WebUtil.getConfigVar('title', 'noVNC');
133 // By default, use the host and port of server that served this file
134 var host = WebUtil.getConfigVar('host', window.location.hostname);
135 var port = WebUtil.getConfigVar('port', window.location.port);
136
137 // if port == 80 (or 443) then it won't be present and should be
138 // set manually
139 if (!port) {
140 if (window.location.protocol.substring(0,5) == 'https') {
141 port = 443;
142 }
143 else if (window.location.protocol.substring(0,4) == 'http') {
144 port = 80;
145 }
146 }
147
148 var password = WebUtil.getConfigVar('password', '');
149 var path = WebUtil.getConfigVar('path', 'websockify');
150
151 // If a token variable is passed in, set the parameter in a cookie.
152 // This is used by nova-novncproxy.
153 var token = WebUtil.getConfigVar('token', null);
154 if (token) {
155 // if token is already present in the path we should use it
156 path = WebUtil.injectParamIfMissing(path, "token", token);
157
158 WebUtil.createCookie('token', token, 1)
159 }
160
161 (function() {
162
163 status("Connecting", "normal");
164
165 if ((!host) || (!port)) {
166 status('Must specify host and port in URL', 'error');
167 }
168
169 var url;
170
171 if (WebUtil.getConfigVar('encrypt',
172 (window.location.protocol === "https:"))) {
173 url = 'wss';
174 } else {
175 url = 'ws';
176 }
177
178 url += '://' + host;
179 if(port) {
180 url += ':' + port;
181 }
182 url += '/' + path;
183
184 rfb = new RFB(document.body, url,
185 { repeaterID: WebUtil.getConfigVar('repeaterID', ''),
186 shared: WebUtil.getConfigVar('shared', true),
187 credentials: { password: password } });
188 rfb.viewOnly = WebUtil.getConfigVar('view_only', false);
189 rfb.addEventListener("connect", connected);
190 rfb.addEventListener("disconnect", disconnected);
191 rfb.addEventListener("credentialsrequired", credentials);
192 rfb.addEventListener("desktopname", updateDesktopName);
193 rfb.scaleViewport = WebUtil.getConfigVar('scale', false);
194 rfb.resizeSession = WebUtil.getConfigVar('resize', false);
195 })();
196 </script>
197 </head>
198
199 <body>
200 <div id="noVNC_status_bar">
201 <div id="noVNC_left_dummy_elem"></div>
202 <div id="noVNC_status">Loading</div>
203 <div id="noVNC_buttons">
204 <input type=button value="Send CtrlAltDel"
205 id="sendCtrlAltDelButton" class="noVNC_shown">
206 </div>
207 </div>
208 </body>
209 </html>