]> git.proxmox.com Git - mirror_novnc.git/blob - vnc_auto.html
Add View Only mode setting.
[mirror_novnc.git] / vnc_auto.html
1 <!DOCTYPE html>
2 <html>
3 <!--
4 noVNC Example: Automatically connect on page load.
5 Copyright (C) 2011 Joel Martin
6 Licensed under LGPL-3 (see LICENSE.txt)
7
8 Connect parameters are provided in query string:
9 http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
10 -->
11 <head>
12 <title>noVNC</title>
13 <meta http-equiv="X-UA-Compatible" content="chrome=1">
14 <link rel="stylesheet" href="include/base.css" title="plain">
15 <!--
16 <script type='text/javascript'
17 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
18 -->
19 <script src="include/vnc.js"></script>
20 </head>
21
22 <body style="margin: 0px;">
23 <div id="noVNC_screen">
24 <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
25 <table border=0 width="100%"><tr>
26 <td><div id="noVNC_status">Loading</div></td>
27 <td width="1%"><div id="noVNC_buttons">
28 <input type=button value="Send CtrlAltDel"
29 id="sendCtrlAltDelButton">
30 </div></td>
31 </tr></table>
32 </div>
33 <canvas id="noVNC_canvas" width="640px" height="20px">
34 Canvas not supported.
35 </canvas>
36 </div>
37
38 <script>
39 /*jslint white: false */
40 /*global window, $, Util, RFB, */
41 "use strict";
42
43 var rfb;
44
45 function passwordRequired(rfb) {
46 var msg;
47 msg = '<form onsubmit="return setPassword();"';
48 msg += ' style="margin-bottom: 0px">';
49 msg += 'Password Required: ';
50 msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
51 msg += '<\/form>';
52 $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
53 $D('noVNC_status').innerHTML = msg;
54 }
55 function setPassword() {
56 rfb.sendPassword($D('password_input').value);
57 return false;
58 }
59 function sendCtrlAltDel() {
60 rfb.sendCtrlAltDel();
61 return false;
62 }
63 function updateState(rfb, state, oldstate, msg) {
64 var s, sb, cad, level;
65 s = $D('noVNC_status');
66 sb = $D('noVNC_status_bar');
67 cad = $D('sendCtrlAltDelButton');
68 switch (state) {
69 case 'failed': level = "error"; break;
70 case 'fatal': level = "error"; break;
71 case 'normal': level = "normal"; break;
72 case 'disconnected': level = "normal"; break;
73 case 'loaded': level = "normal"; break;
74 default: level = "warn"; break;
75 }
76
77 if (state === "normal") { cad.disabled = false; }
78 else { cad.disabled = true; }
79
80 if (typeof(msg) !== 'undefined') {
81 sb.setAttribute("class", "noVNC_status_" + level);
82 s.innerHTML = msg;
83 }
84 }
85
86 window.onload = function () {
87 var host, port, password, path;
88
89 $D('sendCtrlAltDelButton').style.display = "inline";
90 $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
91
92 document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
93 host = WebUtil.getQueryVar('host', null);
94 port = WebUtil.getQueryVar('port', null);
95 password = WebUtil.getQueryVar('password', '');
96 path = WebUtil.getQueryVar('path', '');
97 if ((!host) || (!port)) {
98 updateState('failed',
99 "Must specify host and port in URL");
100 return;
101 }
102
103 rfb = new RFB({'target': $D('noVNC_canvas'),
104 'encrypt': WebUtil.getQueryVar('encrypt', false),
105 'true_color': WebUtil.getQueryVar('true_color', true),
106 'local_cursor': WebUtil.getQueryVar('cursor', true),
107 'shared': WebUtil.getQueryVar('shared', true),
108 'view_only': WebUtil.getQueryVar('view_only', false),
109 'updateState': updateState,
110 'onPasswordRequired': passwordRequired});
111 rfb.connect(host, port, password, path);
112 };
113 </script>
114
115 </body>
116 </html>
117