]> git.proxmox.com Git - mirror_novnc.git/blob - vnc_auto.html
Keyboard Handling [6/8]: Update everything to include the new keyboard handling scripts
[mirror_novnc.git] / vnc_auto.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4
5 <!--
6 noVNC example: simple example using default UI
7 Copyright (C) 2012 Joel Martin
8 Copyright (C) 2013 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&true_color=1
14 -->
15 <title>noVNC</title>
16
17 <meta charset="utf-8">
18
19 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
20 Remove this if you use the .htaccess -->
21 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
22
23 <!-- Apple iOS Safari settings -->
24 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
25 <meta name="apple-mobile-web-app-capable" content="yes" />
26 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
27 <!-- App Start Icon -->
28 <link rel="apple-touch-startup-image" href="images/screen_320x460.png" />
29 <!-- For iOS devices set the icon to use if user bookmarks app on their homescreen -->
30 <link rel="apple-touch-icon" href="images/screen_57x57.png">
31 <!--
32 <link rel="apple-touch-icon-precomposed" href="images/screen_57x57.png" />
33 -->
34
35
36 <!-- Stylesheets -->
37 <link rel="stylesheet" href="include/base.css" title="plain">
38
39 <!--
40 <script type='text/javascript'
41 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
42 -->
43 <script src="include/util.js"></script>
44 </head>
45
46 <body style="margin: 0px;">
47 <div id="noVNC_screen">
48 <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
49 <table border=0 width="100%"><tr>
50 <td><div id="noVNC_status" style="position: relative; height: auto;">
51 Loading
52 </div></td>
53 <td width="1%"><div id="noVNC_buttons">
54 <input type=button value="Send CtrlAltDel"
55 id="sendCtrlAltDelButton">
56 </div></td>
57 </tr></table>
58 </div>
59 <canvas id="noVNC_canvas" width="640px" height="20px">
60 Canvas not supported.
61 </canvas>
62 </div>
63
64 <script>
65 /*jslint white: false */
66 /*global window, $, Util, RFB, */
67 "use strict";
68
69 // Load supporting scripts
70 Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
71 "keysymdef.js", "keyboard.js", "input.js", "display.js",
72 "jsunzip.js", "rfb.js"]);
73
74 var rfb;
75
76 function passwordRequired(rfb) {
77 var msg;
78 msg = '<form onsubmit="return setPassword();"';
79 msg += ' style="margin-bottom: 0px">';
80 msg += 'Password Required: ';
81 msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
82 msg += '<\/form>';
83 $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
84 $D('noVNC_status').innerHTML = msg;
85 }
86 function setPassword() {
87 rfb.sendPassword($D('password_input').value);
88 return false;
89 }
90 function sendCtrlAltDel() {
91 rfb.sendCtrlAltDel();
92 return false;
93 }
94 function updateState(rfb, state, oldstate, msg) {
95 var s, sb, cad, level;
96 s = $D('noVNC_status');
97 sb = $D('noVNC_status_bar');
98 cad = $D('sendCtrlAltDelButton');
99 switch (state) {
100 case 'failed': level = "error"; break;
101 case 'fatal': level = "error"; break;
102 case 'normal': level = "normal"; break;
103 case 'disconnected': level = "normal"; break;
104 case 'loaded': level = "normal"; break;
105 default: level = "warn"; break;
106 }
107
108 if (state === "normal") { cad.disabled = false; }
109 else { cad.disabled = true; }
110
111 if (typeof(msg) !== 'undefined') {
112 sb.setAttribute("class", "noVNC_status_" + level);
113 s.innerHTML = msg;
114 }
115 }
116
117 window.onscriptsload = function () {
118 var host, port, password, path, token;
119
120 $D('sendCtrlAltDelButton').style.display = "inline";
121 $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
122
123 WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn'));
124 document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
125 // By default, use the host and port of server that served this file
126 host = WebUtil.getQueryVar('host', window.location.hostname);
127 port = WebUtil.getQueryVar('port', window.location.port);
128
129 // if port == 80 (or 443) then it won't be present and should be
130 // set manually
131 if (!port) {
132 if (window.location.protocol.substring(0,5) == 'https') {
133 port = 443;
134 }
135 else if (window.location.protocol.substring(0,4) == 'http') {
136 port = 80;
137 }
138 }
139
140 // If a token variable is passed in, set the parameter in a cookie.
141 // This is used by nova-novncproxy.
142 token = WebUtil.getQueryVar('token', null);
143 if (token) {
144 WebUtil.createCookie('token', token, 1)
145 }
146
147 password = WebUtil.getQueryVar('password', '');
148 path = WebUtil.getQueryVar('path', 'websockify');
149
150 if ((!host) || (!port)) {
151 updateState('failed',
152 "Must specify host and port in URL");
153 return;
154 }
155
156 rfb = new RFB({'target': $D('noVNC_canvas'),
157 'encrypt': WebUtil.getQueryVar('encrypt',
158 (window.location.protocol === "https:")),
159 'repeaterID': WebUtil.getQueryVar('repeaterID', ''),
160 'true_color': WebUtil.getQueryVar('true_color', true),
161 'local_cursor': WebUtil.getQueryVar('cursor', true),
162 'shared': WebUtil.getQueryVar('shared', true),
163 'view_only': WebUtil.getQueryVar('view_only', false),
164 'updateState': updateState,
165 'onPasswordRequired': passwordRequired});
166 rfb.connect(host, port, password, path);
167 };
168 </script>
169
170 </body>
171 </html>