]> git.proxmox.com Git - mirror_novnc.git/blame - vnc_lite.html
Drop support for legacy Edge
[mirror_novnc.git] / vnc_lite.html
CommitLineData
40f281eb 1<!DOCTYPE html>
80c52ba7 2<html lang="en">
e84101b3
3<head>
4
82744aa8 5 <!--
83391ffc 6 noVNC example: lightweight example using minimal UI and features
8c2866df
SM
7
8 This is a self-contained file which doesn't import WebUtil or external CSS.
9
412d9306 10 Copyright (C) 2019 The noVNC Authors
1d728ace 11 noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
d58f8b51 12 This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
d595e656
JM
13
14 Connect parameters are provided in query string:
51f9f009 15 http://example.com/?host=HOST&port=PORT&scale=true
d595e656 16 -->
e84101b3
17 <title>noVNC</title>
18
2aa3b5bc 19 <meta charset="utf-8">
33f5d3bd 20
78bbf6ba
SM
21 <!-- Always force latest IE rendering engine (even in intranet) &
22 Chrome Frame. Remove this if you use the .htaccess -->
8f230f45 23 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
78bbf6ba 24
45c644a6 25 <style>
e0d4e5a1
SM
26
27 body {
28 margin: 0;
de79ae92 29 background-color: dimgrey;
e0d4e5a1
SM
30 height: 100%;
31 display: flex;
32 flex-direction: column;
33 }
34 html {
e0d4e5a1
SM
35 height: 100%;
36 }
37
8613f6f4 38 #top_bar {
de79ae92 39 background-color: #6e84a3;
011e4bff
SM
40 color: white;
41 font: bold 12px Helvetica;
42 padding: 6px 5px 4px 5px;
de79ae92 43 border-bottom: 1px outset;
e0d4e5a1 44 }
8613f6f4 45 #status {
011e4bff 46 text-align: center;
e0d4e5a1 47 }
011e4bff
SM
48 #sendCtrlAltDelButton {
49 position: fixed;
50 top: 0px;
51 right: 0px;
52 border: 1px outset;
53 padding: 5px 5px 4px 5px;
54 cursor: pointer;
e0d4e5a1
SM
55 }
56
1c945f81
SM
57 #screen {
58 flex: 1; /* fill remaining space */
59 overflow: hidden;
60 }
61
e0d4e5a1 62 </style>
e84101b3 63
bf826444 64 <script type="module" crossorigin="anonymous">
8c2866df 65 // RFB holds the API to connect and communicate with a VNC server
7569cdc2 66 import RFB from './core/rfb.js';
6f4b1e40 67
25551b6b
SM
68 let rfb;
69 let desktopName;
8db09746 70
26d51e49
SM
71 // When this function is called we have
72 // successfully connected to a server
73 function connectedToServer(e) {
26d51e49
SM
74 status("Connected to " + desktopName);
75 }
76
77 // This function is called when we are disconnected
78 function disconnectedFromServer(e) {
26d51e49
SM
79 if (e.detail.clean) {
80 status("Disconnected");
81 } else {
82 status("Something went wrong, connection is closed");
83 }
3bb12056 84 }
8c2866df
SM
85
86 // When this function is called, the server requires
87 // credentials to authenticate
c756665e 88 function credentialsAreRequired(e) {
5271e300
SM
89 const password = prompt("Password Required:");
90 rfb.sendCredentials({ password: password });
d890e864 91 }
8c2866df 92
26d51e49
SM
93 // When this function is called we have received
94 // a desktop name from the server
95 function updateDesktopName(e) {
96 desktopName = e.detail.name;
97 }
98
8c2866df
SM
99 // Since most operating systems will catch Ctrl+Alt+Del
100 // before they get a chance to be intercepted by the browser,
101 // we provide a way to emulate this key sequence.
63708ff5 102 function sendCtrlAltDel() {
8db09746 103 rfb.sendCtrlAltDel();
a8edf9d8 104 return false;
63708ff5 105 }
26d51e49 106
8c2866df 107 // Show a status text in the top bar
de79ae92 108 function status(text) {
8613f6f4 109 document.getElementById('status').textContent = text;
3bb12056 110 }
91308399 111
6517c498
SM
112 // This function extracts the value of one variable from the
113 // query string. If the variable isn't defined in the URL
114 // it returns the default value instead.
115 function readQueryVariable(name, defaultValue) {
116 // A URL with a query parameter can look like this:
117 // https://www.example.com?myqueryparam=myvalue
118 //
119 // Note that we use location.href instead of location.search
120 // because Firefox < 53 has a bug w.r.t location.search
121 const re = new RegExp('.*[?&]' + name + '=([^&#]*)'),
122 match = document.location.href.match(re);
6517c498
SM
123
124 if (match) {
125 // We have to decode the URL since want the cleartext value
126 return decodeURIComponent(match[1]);
127 }
128
129 return defaultValue;
130 }
131
e20f0ee9
SM
132 document.getElementById('sendCtrlAltDelButton')
133 .onclick = sendCtrlAltDel;
91308399 134
6517c498 135 // Read parameters specified in the URL query string
7569cdc2 136 // By default, use the host and port of server that served this file
25551b6b
SM
137 const host = readQueryVariable('host', window.location.hostname);
138 let port = readQueryVariable('port', window.location.port);
06a8f7d9 139 const password = readQueryVariable('password');
25551b6b 140 const path = readQueryVariable('path', 'websockify');
c55f05f6 141
8c2866df
SM
142 // | | | | | |
143 // | | | Connect | | |
144 // v v v v v v
0139b256 145
25551b6b 146 status("Connecting");
91308399 147
25551b6b
SM
148 // Build the websocket URL used to connect
149 let url;
150 if (window.location.protocol === "https:") {
151 url = 'wss';
152 } else {
153 url = 'ws';
154 }
155 url += '://' + host;
156 if(port) {
157 url += ':' + port;
158 }
159 url += '/' + path;
160
161 // Creating a new RFB object will start a new connection
1c945f81 162 rfb = new RFB(document.getElementById('screen'), url,
25551b6b
SM
163 { credentials: { password: password } });
164
165 // Add listeners to important events from the RFB module
c756665e
SM
166 rfb.addEventListener("connect", connectedToServer);
167 rfb.addEventListener("disconnect", disconnectedFromServer);
168 rfb.addEventListener("credentialsrequired", credentialsAreRequired);
25551b6b
SM
169 rfb.addEventListener("desktopname", updateDesktopName);
170
171 // Set parameters that can be changed on an active connection
172 rfb.viewOnly = readQueryVariable('view_only', false);
173 rfb.scaleViewport = readQueryVariable('scale', false);
7569cdc2
SR
174 </script>
175</head>
176
178bf8ec 177<body>
8613f6f4
SM
178 <div id="top_bar">
179 <div id="status">Loading</div>
180 <div id="sendCtrlAltDelButton">Send CtrlAltDel</div>
181 </div>
1c945f81
SM
182 <div id="screen">
183 <!-- This is where the remote screen will appear -->
184 </div>
178bf8ec 185</body>
91308399 186</html>