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