]> git.proxmox.com Git - mirror_novnc.git/blame - vnc_auto.html
Move over comment about URL connect parameters from vnc_auto.html.
[mirror_novnc.git] / vnc_auto.html
CommitLineData
40f281eb 1<!DOCTYPE html>
91308399 2<html>
e84101b3
3<head>
4
d595e656 5 <!--
d58f8b51
JM
6 noVNC example: simple example using default UI
7 Copyright (C) 2012 Joel Martin
1d728ace 8 noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
d58f8b51 9 This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
d595e656
JM
10
11 Connect parameters are provided in query string:
12 http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
13 -->
e84101b3
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 -->
6f4b1e40 28 <script src="include/util.js"></script>
e84101b3 29</head>
91308399 30
e84101b3
31<body style="margin: 0px;">
32 <div id="noVNC_screen">
a7f55899 33 <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
8db09746 34 <table border=0 width="100%"><tr>
a7f55899
JM
35 <td><div id="noVNC_status">Loading</div></td>
36 <td width="1%"><div id="noVNC_buttons">
63708ff5 37 <input type=button value="Send CtrlAltDel"
8db09746
JM
38 id="sendCtrlAltDelButton">
39 </div></td>
63708ff5
JM
40 </tr></table>
41 </div>
a7f55899 42 <canvas id="noVNC_canvas" width="640px" height="20px">
91308399
JM
43 Canvas not supported.
44 </canvas>
45 </div>
91308399 46
8db09746
JM
47 <script>
48 /*jslint white: false */
49 /*global window, $, Util, RFB, */
50 "use strict";
51
6f4b1e40
JM
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
8db09746
JM
56 var rfb;
57
d890e864
JM
58 function passwordRequired(rfb) {
59 var msg;
60 msg = '<form onsubmit="return setPassword();"';
61 msg += ' style="margin-bottom: 0px">';
62 msg += 'Password Required: ';
a7f55899 63 msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
d890e864 64 msg += '<\/form>';
a7f55899
JM
65 $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
66 $D('noVNC_status').innerHTML = msg;
d890e864 67 }
91308399 68 function setPassword() {
e4671910 69 rfb.sendPassword($D('password_input').value);
91308399
JM
70 return false;
71 }
63708ff5 72 function sendCtrlAltDel() {
8db09746 73 rfb.sendCtrlAltDel();
a8edf9d8 74 return false;
63708ff5 75 }
8db09746 76 function updateState(rfb, state, oldstate, msg) {
d890e864 77 var s, sb, cad, level;
a7f55899
JM
78 s = $D('noVNC_status');
79 sb = $D('noVNC_status_bar');
e4671910 80 cad = $D('sendCtrlAltDelButton');
91308399 81 switch (state) {
d890e864
JM
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;
91308399
JM
88 }
89
160fabf6
JM
90 if (state === "normal") { cad.disabled = false; }
91 else { cad.disabled = true; }
92
91308399 93 if (typeof(msg) !== 'undefined') {
a7f55899 94 sb.setAttribute("class", "noVNC_status_" + level);
91308399
JM
95 s.innerHTML = msg;
96 }
91308399
JM
97 }
98
6f4b1e40 99 window.onscriptsload = function () {
9ebc84f2 100 var host, port, password, path, token;
91308399 101
a7f55899 102 $D('sendCtrlAltDelButton').style.display = "inline";
e4671910 103 $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
8db09746 104
2cde6e43 105 WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn'));
2270c7b5 106 document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
bd96e919
JM
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);
0139b256
AY
110
111 // If a token variable is passed in, set the parameter in a cookie.
112 // This is used by nova-novncproxy.
4c75210a 113 token = WebUtil.getQueryVar('token', null);
0139b256 114 if (token) {
0139b256
AY
115 WebUtil.createCookie('token', token, 1)
116 }
117
8d5d2c82 118 password = WebUtil.getQueryVar('password', '');
523cc4d6 119 path = WebUtil.getQueryVar('path', 'websockify');
b50f3406 120
91308399
JM
121 if ((!host) || (!port)) {
122 updateState('failed',
123 "Must specify host and port in URL");
124 return;
125 }
126
a7f55899 127 rfb = new RFB({'target': $D('noVNC_canvas'),
1af3e54b
JM
128 'encrypt': WebUtil.getQueryVar('encrypt',
129 (window.location.protocol === "https:")),
9ebc84f2 130 'repeaterID': WebUtil.getQueryVar('repeaterID', ''),
f1a9971c
JM
131 'true_color': WebUtil.getQueryVar('true_color', true),
132 'local_cursor': WebUtil.getQueryVar('cursor', true),
133 'shared': WebUtil.getQueryVar('shared', true),
06a9ef0c 134 'view_only': WebUtil.getQueryVar('view_only', false),
d890e864
JM
135 'updateState': updateState,
136 'onPasswordRequired': passwordRequired});
9ebc84f2 137 rfb.connect(host, port, password, path);
8db09746
JM
138 };
139 </script>
da6dd893 140
8db09746 141 </body>
91308399
JM
142</html>
143