]> git.proxmox.com Git - mirror_novnc.git/blob - vnc_auto.html
Catch exceptions in cursor detection.
[mirror_novnc.git] / vnc_auto.html
1 <!--
2 noVNC Example: Automatically connect on page load.
3
4 Connect parameters are provided in query string:
5 http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
6 -->
7 <html>
8 <head>
9 <title>VNC Client</title>
10 <link rel="stylesheet" href="include/plain.css" TITLE="plain">
11 <link rel="Alternate StyleSheet" href="include/black.css" TITLE="Black">
12 <!--
13 <script type='text/javascript'
14 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
15 -->
16 <script src="include/vnc.js"></script>
17 </head>
18
19 <body style="margin: 0px;">
20 <div id="VNC_screen">
21 <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">
22 <table border=0 width=100%><tr>
23 <td><div id="VNC_status">Loading</div></td>
24 <td width=1%><div id="VNC_buttons">
25 <input type=button value="Send CtrlAltDel"
26 id="sendCtrlAltDelButton"
27 onclick="sendCtrlAltDel();"></div></td>
28 </tr></table>
29 </div>
30 <canvas id="VNC_canvas" width="640px" height="20px">
31 Canvas not supported.
32 </canvas>
33 </div>
34 </body>
35
36 <script>
37 function setPassword() {
38 RFB.sendPassword($('password_input').value);
39 return false;
40 }
41 function sendCtrlAltDel() {
42 RFB.sendCtrlAltDel();
43 return false;
44 }
45 function updateState(state, msg) {
46 var s, sb, klass, html;
47 s = $('VNC_status');
48 sb = $('VNC_status_bar');
49 cad = $('sendCtrlAltDelButton');
50 switch (state) {
51 case 'failed':
52 case 'fatal':
53 klass = "VNC_status_error";
54 break;
55 case 'normal':
56 klass = "VNC_status_normal";
57 break;
58 case 'disconnected':
59 case 'loaded':
60 klass = "VNC_status_normal";
61 break;
62 case 'password':
63 msg = '<form onsubmit="return setPassword();"';
64 msg += ' style="margin-bottom: 0px">';
65 msg += 'Password Required: ';
66 msg += '<input type=password size=10 id="password_input" class="VNC_status">';
67 msg += '</form>';
68 // Fall through
69 default:
70 klass = "VNC_status_warn";
71 }
72
73 if (state === "normal") { cad.disabled = false; }
74 else { cad.disabled = true; }
75
76 if (typeof(msg) !== 'undefined') {
77 sb.setAttribute("class", klass);
78 s.innerHTML = msg;
79 }
80 }
81
82 window.onload = function () {
83 var host, port, password;
84
85 host = Util.getQueryVar('host', null);
86 port = Util.getQueryVar('port', null);
87 password = Util.getQueryVar('password', '');
88 if ((!host) || (!port)) {
89 updateState('failed',
90 "Must specify host and port in URL");
91 return;
92 }
93
94 RFB.setEncrypt(Util.getQueryVar('encrypt', true));
95 RFB.setBase64(Util.getQueryVar('base64', true));
96 RFB.setTrueColor(Util.getQueryVar('true_color', true));
97 RFB.setCursor(Util.getQueryVar('cursor', true));
98 RFB.setUpdateState(updateState);
99
100 RFB.load();
101 RFB.connect(host, port, password);
102 }
103 </script>
104 </html>
105