]> git.proxmox.com Git - mirror_novnc.git/blame_incremental - vnc_auto.html
Merge pull request #191 from takaha/altgr
[mirror_novnc.git] / vnc_auto.html
... / ...
CommitLineData
1<!DOCTYPE html>
2<html>
3 <!--
4 noVNC example: simple example using default UI
5 Copyright (C) 2012 Joel Martin
6 noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
7 This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
8
9 Connect parameters are provided in query string:
10 http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
11 -->
12 <head>
13 <title>noVNC</title>
14 <meta http-equiv="X-UA-Compatible" content="chrome=1">
15 <link rel="stylesheet" href="include/base.css" title="plain">
16 <!--
17 <script type='text/javascript'
18 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
19 -->
20 <script src="include/vnc.js"></script>
21 </head>
22
23 <body style="margin: 0px;">
24 <div id="noVNC_screen">
25 <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
26 <table border=0 width="100%"><tr>
27 <td><div id="noVNC_status">Loading</div></td>
28 <td width="1%"><div id="noVNC_buttons">
29 <input type=button value="Send CtrlAltDel"
30 id="sendCtrlAltDelButton">
31 </div></td>
32 </tr></table>
33 </div>
34 <canvas id="noVNC_canvas" width="640px" height="20px">
35 Canvas not supported.
36 </canvas>
37 </div>
38
39 <script>
40 /*jslint white: false */
41 /*global window, $, Util, RFB, */
42 "use strict";
43
44 var rfb;
45
46 function passwordRequired(rfb) {
47 var msg;
48 msg = '<form onsubmit="return setPassword();"';
49 msg += ' style="margin-bottom: 0px">';
50 msg += 'Password Required: ';
51 msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
52 msg += '<\/form>';
53 $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
54 $D('noVNC_status').innerHTML = msg;
55 }
56 function setPassword() {
57 rfb.sendPassword($D('password_input').value);
58 return false;
59 }
60 function sendCtrlAltDel() {
61 rfb.sendCtrlAltDel();
62 return false;
63 }
64 function updateState(rfb, state, oldstate, msg) {
65 var s, sb, cad, level;
66 s = $D('noVNC_status');
67 sb = $D('noVNC_status_bar');
68 cad = $D('sendCtrlAltDelButton');
69 switch (state) {
70 case 'failed': level = "error"; break;
71 case 'fatal': level = "error"; break;
72 case 'normal': level = "normal"; break;
73 case 'disconnected': level = "normal"; break;
74 case 'loaded': level = "normal"; break;
75 default: level = "warn"; break;
76 }
77
78 if (state === "normal") { cad.disabled = false; }
79 else { cad.disabled = true; }
80
81 if (typeof(msg) !== 'undefined') {
82 sb.setAttribute("class", "noVNC_status_" + level);
83 s.innerHTML = msg;
84 }
85 }
86
87 window.onload = function () {
88 var host, port, password, path, token;
89
90 $D('sendCtrlAltDelButton').style.display = "inline";
91 $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
92
93 WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn'));
94 document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
95 // By default, use the host and port of server that served this file
96 host = WebUtil.getQueryVar('host', window.location.hostname);
97 port = WebUtil.getQueryVar('port', window.location.port);
98
99 // If a token variable is passed in, set the parameter in a cookie.
100 // This is used by nova-novncproxy.
101 token = WebUtil.getQueryVar('token', null);
102 if (token) {
103 WebUtil.createCookie('token', token, 1)
104 }
105
106 password = WebUtil.getQueryVar('password', '');
107 path = WebUtil.getQueryVar('path', 'websockify');
108
109 if ((!host) || (!port)) {
110 updateState('failed',
111 "Must specify host and port in URL");
112 return;
113 }
114
115 rfb = new RFB({'target': $D('noVNC_canvas'),
116 'encrypt': WebUtil.getQueryVar('encrypt',
117 (window.location.protocol === "https:")),
118 'repeaterID': WebUtil.getQueryVar('repeaterID', ''),
119 'true_color': WebUtil.getQueryVar('true_color', true),
120 'local_cursor': WebUtil.getQueryVar('cursor', true),
121 'shared': WebUtil.getQueryVar('shared', true),
122 'view_only': WebUtil.getQueryVar('view_only', false),
123 'updateState': updateState,
124 'onPasswordRequired': passwordRequired});
125 rfb.connect(host, port, password, path);
126 };
127 </script>
128
129 </body>
130</html>
131