]> git.proxmox.com Git - mirror_novnc.git/blob - vnc_auto.html
Tweak order/whitespace/style to match vnc.html more closely. No
[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 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
17 Remove this if you use the .htaccess -->
18 <meta http-equiv="X-UA-Compatible" content="chrome=1">
19
20
21 <!-- Stylesheets -->
22 <link rel="stylesheet" href="include/base.css" title="plain">
23
24 <!--
25 <script type='text/javascript'
26 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
27 -->
28 <script src="include/util.js"></script>
29 </head>
30
31 <body style="margin: 0px;">
32 <div id="noVNC_screen">
33 <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
34 <table border=0 width="100%"><tr>
35 <td><div id="noVNC_status">Loading</div></td>
36 <td width="1%"><div id="noVNC_buttons">
37 <input type=button value="Send CtrlAltDel"
38 id="sendCtrlAltDelButton">
39 </div></td>
40 </tr></table>
41 </div>
42 <canvas id="noVNC_canvas" width="640px" height="20px">
43 Canvas not supported.
44 </canvas>
45 </div>
46
47 <script>
48 /*jslint white: false */
49 /*global window, $, Util, RFB, */
50 "use strict";
51
52 // Load supporting scripts
53 Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
54 "input.js", "display.js", "jsunzip.js", "rfb.js"]);
55
56 var rfb;
57
58 function passwordRequired(rfb) {
59 var msg;
60 msg = '<form onsubmit="return setPassword();"';
61 msg += ' style="margin-bottom: 0px">';
62 msg += 'Password Required: ';
63 msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
64 msg += '<\/form>';
65 $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
66 $D('noVNC_status').innerHTML = msg;
67 }
68 function setPassword() {
69 rfb.sendPassword($D('password_input').value);
70 return false;
71 }
72 function sendCtrlAltDel() {
73 rfb.sendCtrlAltDel();
74 return false;
75 }
76 function updateState(rfb, state, oldstate, msg) {
77 var s, sb, cad, level;
78 s = $D('noVNC_status');
79 sb = $D('noVNC_status_bar');
80 cad = $D('sendCtrlAltDelButton');
81 switch (state) {
82 case 'failed': level = "error"; break;
83 case 'fatal': level = "error"; break;
84 case 'normal': level = "normal"; break;
85 case 'disconnected': level = "normal"; break;
86 case 'loaded': level = "normal"; break;
87 default: level = "warn"; break;
88 }
89
90 if (state === "normal") { cad.disabled = false; }
91 else { cad.disabled = true; }
92
93 if (typeof(msg) !== 'undefined') {
94 sb.setAttribute("class", "noVNC_status_" + level);
95 s.innerHTML = msg;
96 }
97 }
98
99 window.onscriptsload = function () {
100 var host, port, password, path, token;
101
102 $D('sendCtrlAltDelButton').style.display = "inline";
103 $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
104
105 WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn'));
106 document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
107 // By default, use the host and port of server that served this file
108 host = WebUtil.getQueryVar('host', window.location.hostname);
109 port = WebUtil.getQueryVar('port', window.location.port);
110
111 // If a token variable is passed in, set the parameter in a cookie.
112 // This is used by nova-novncproxy.
113 token = WebUtil.getQueryVar('token', null);
114 if (token) {
115 WebUtil.createCookie('token', token, 1)
116 }
117
118 password = WebUtil.getQueryVar('password', '');
119 path = WebUtil.getQueryVar('path', 'websockify');
120
121 if ((!host) || (!port)) {
122 updateState('failed',
123 "Must specify host and port in URL");
124 return;
125 }
126
127 rfb = new RFB({'target': $D('noVNC_canvas'),
128 'encrypt': WebUtil.getQueryVar('encrypt',
129 (window.location.protocol === "https:")),
130 'repeaterID': WebUtil.getQueryVar('repeaterID', ''),
131 'true_color': WebUtil.getQueryVar('true_color', true),
132 'local_cursor': WebUtil.getQueryVar('cursor', true),
133 'shared': WebUtil.getQueryVar('shared', true),
134 'view_only': WebUtil.getQueryVar('view_only', false),
135 'updateState': updateState,
136 'onPasswordRequired': passwordRequired});
137 rfb.connect(host, port, password, path);
138 };
139 </script>
140
141 </body>
142 </html>
143