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