]> git.proxmox.com Git - mirror_novnc.git/blame - vnc_lite.html
Move css rules for vnc_lite to the html
[mirror_novnc.git] / vnc_lite.html
CommitLineData
40f281eb 1<!DOCTYPE html>
91308399 2<html>
e84101b3
3<head>
4
82744aa8 5 <!--
83391ffc 6 noVNC example: lightweight example using minimal UI and features
d58f8b51 7 Copyright (C) 2012 Joel Martin
0f207c80 8 Copyright (C) 2018 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
17 <title>noVNC</title>
18
33f5d3bd
19 <meta charset="utf-8">
20
e84101b3
21 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
22 Remove this if you use the .htaccess -->
33f5d3bd
23 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
24
e0d4e5a1
SM
25 <style type="text/css">
26
27 body {
28 margin: 0;
29 background-color: #313131;
30 border-bottom-right-radius: 800px 600px;
31 height: 100%;
32 display: flex;
33 flex-direction: column;
34 }
35 html {
36 background-color: #494949;
37 height: 100%;
38 }
39
40 #noVNC_status_bar {
41 width: 100%;
42 display: flex;
43 justify-content: space-between;
44 }
45 #noVNC_status {
46 color: #ffffff;
47 font: bold 12px Helvetica;
48 margin: auto;
49 }
50
51 .noVNC_status_normal {
52 background: linear-gradient(#b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%);
53 }
54 .noVNC_status_error {
55 background: linear-gradient(#c83737 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%);
56 }
57 .noVNC_status_warn {
58 background: linear-gradient(#b4b41e 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%);
59 }
60
61 .noNVC_shown {
62 display: inline;
63 }
64 .noVNC_hidden {
65 display: none;
66 }
67
68 #noVNC_left_dummy_elem {
69 flex: 1;
70 }
71
72 #noVNC_buttons {
73 padding: 1px;
74 flex: 1;
75 display: flex;
76 justify-content: flex-end;
77 }
78
79 </style>
e84101b3 80
7569cdc2
SR
81 <!-- promise polyfills promises for IE11 -->
82 <script src="vendor/promise.js"></script>
14ecdc62
FC
83 <!-- ES2015/ES6 modules polyfill -->
84 <script type="module">
85 window._noVNC_has_module_support = true;
86 </script>
87 <script>
88 window.addEventListener("load", function() {
89 if (window._noVNC_has_module_support) return;
90 var loader = document.createElement("script");
91 loader.src = "vendor/browser-es-module-loader/dist/browser-es-module-loader.js";
92 document.head.appendChild(loader);
93 });
94 </script>
95
96 <!-- actual script modules -->
bf826444 97 <script type="module" crossorigin="anonymous">
6f4b1e40 98 // Load supporting scripts
7569cdc2
SR
99 import * as WebUtil from './app/webutil.js';
100 import RFB from './core/rfb.js';
6f4b1e40 101
8db09746 102 var rfb;
3bb12056 103 var desktopName;
8db09746 104
e89eef94
PO
105 function updateDesktopName(e) {
106 desktopName = e.detail.name;
3bb12056 107 }
e89eef94 108 function credentials(e) {
7d714b15 109 var html;
c464f47e 110
7569cdc2 111 var form = document.createElement('form');
cf3b5282 112 form.innerHTML = '<label></label>';
8167e459 113 form.innerHTML += '<input type=password size=10 id="password_input">';
7569cdc2 114 form.onsubmit = setPassword;
6048299a
SR
115
116 // bypass status() because it sets text content
117 document.getElementById('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
7569cdc2
SR
118 document.getElementById('noVNC_status').innerHTML = '';
119 document.getElementById('noVNC_status').appendChild(form);
430f00d6 120 document.getElementById('noVNC_status').querySelector('label').textContent = 'Password Required: ';
d890e864 121 }
91308399 122 function setPassword() {
430f00d6 123 rfb.sendCredentials({ password: document.getElementById('password_input').value });
91308399
JM
124 return false;
125 }
63708ff5 126 function sendCtrlAltDel() {
8db09746 127 rfb.sendCtrlAltDel();
a8edf9d8 128 return false;
63708ff5 129 }
3bb12056
SM
130 function status(text, level) {
131 switch (level) {
132 case 'normal':
133 case 'warn':
134 case 'error':
135 break;
136 default:
137 level = "warn";
138 }
dc905e85 139 document.getElementById('noVNC_status_bar').className = "noVNC_status_" + level;
6048299a 140 document.getElementById('noVNC_status').textContent = text;
3bb12056 141 }
91308399 142
ee5cae9f
SM
143 function connected(e) {
144 document.getElementById('sendCtrlAltDelButton').disabled = false;
ee5cae9f
SM
145 if (WebUtil.getConfigVar('encrypt',
146 (window.location.protocol === "https:"))) {
c995c086 147 status("Connected (encrypted) to " + desktopName, "normal");
fb35d50f 148 } else {
c995c086 149 status("Connected (unencrypted) to " + desktopName, "normal");
fb35d50f 150 }
3bb12056 151 }
ee5cae9f
SM
152
153 function disconnected(e) {
154 document.getElementById('sendCtrlAltDelButton').disabled = true;
d472f3f1 155 if (e.detail.clean) {
ee5cae9f 156 status("Disconnected", "normal");
d472f3f1
SM
157 } else {
158 status("Something went wrong, connection is closed", "error");
91308399 159 }
91308399
JM
160 }
161
7569cdc2 162 document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
91308399 163
7569cdc2 164 WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn'));
08cd672e 165 document.title = WebUtil.getConfigVar('title', 'noVNC');
7569cdc2
SR
166 // By default, use the host and port of server that served this file
167 var host = WebUtil.getConfigVar('host', window.location.hostname);
168 var port = WebUtil.getConfigVar('port', window.location.port);
8db09746 169
7569cdc2
SR
170 // if port == 80 (or 443) then it won't be present and should be
171 // set manually
172 if (!port) {
173 if (window.location.protocol.substring(0,5) == 'https') {
174 port = 443;
175 }
176 else if (window.location.protocol.substring(0,4) == 'http') {
177 port = 80;
e83b9e03 178 }
7569cdc2 179 }
e83b9e03 180
7569cdc2
SR
181 var password = WebUtil.getConfigVar('password', '');
182 var path = WebUtil.getConfigVar('path', 'websockify');
c55f05f6 183
7569cdc2
SR
184 // If a token variable is passed in, set the parameter in a cookie.
185 // This is used by nova-novncproxy.
186 var token = WebUtil.getConfigVar('token', null);
187 if (token) {
188 // if token is already present in the path we should use it
189 path = WebUtil.injectParamIfMissing(path, "token", token);
c55f05f6 190
7569cdc2
SR
191 WebUtil.createCookie('token', token, 1)
192 }
c55f05f6 193
7569cdc2 194 (function() {
0139b256 195
ee5cae9f
SM
196 status("Connecting", "normal");
197
91308399 198 if ((!host) || (!port)) {
3bb12056 199 status('Must specify host and port in URL', 'error');
91308399
JM
200 }
201
5b4e5d01
PO
202 var url;
203
204 if (WebUtil.getConfigVar('encrypt',
205 (window.location.protocol === "https:"))) {
206 url = 'wss';
207 } else {
208 url = 'ws';
209 }
210
211 url += '://' + host;
212 if(port) {
213 url += ':' + port;
d9fc1c7b 214 }
5b4e5d01 215 url += '/' + path;
d9fc1c7b 216
9b84f516 217 rfb = new RFB(document.body, url,
2f4516f2
PO
218 { repeaterID: WebUtil.getConfigVar('repeaterID', ''),
219 shared: WebUtil.getConfigVar('shared', true),
220 credentials: { password: password } });
5b20d338 221 rfb.viewOnly = WebUtil.getConfigVar('view_only', false);
ee5cae9f
SM
222 rfb.addEventListener("connect", connected);
223 rfb.addEventListener("disconnect", disconnected);
e89eef94
PO
224 rfb.addEventListener("credentialsrequired", credentials);
225 rfb.addEventListener("desktopname", updateDesktopName);
bd2ce0ca 226 rfb.scaleViewport = WebUtil.getConfigVar('scale', false);
9b84f516 227 rfb.resizeSession = WebUtil.getConfigVar('resize', false);
7569cdc2
SR
228 })();
229 </script>
230</head>
231
178bf8ec 232<body>
dc905e85 233 <div id="noVNC_status_bar">
4023a6e1
SM
234 <div id="noVNC_left_dummy_elem"></div>
235 <div id="noVNC_status">Loading</div>
236 <div id="noVNC_buttons">
237 <input type=button value="Send CtrlAltDel"
238 id="sendCtrlAltDelButton" class="noVNC_shown">
4023a6e1 239 </div>
178bf8ec 240 </div>
178bf8ec 241</body>
91308399 242</html>