]> git.proxmox.com Git - mirror_novnc.git/blame - vnc_auto.html
vnc_playback.html: print frame_idx on error.
[mirror_novnc.git] / vnc_auto.html
CommitLineData
91308399
JM
1<!--
2noVNC Example: Automatically connect on page load.
3
4Connect 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>
8db09746 10 <link rel="stylesheet" href="include/plain.css" title="plain">
a93c9555
JM
11 <!--
12 <script type='text/javascript'
13 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
14 -->
15 <script src="include/vnc.js"></script>
91308399
JM
16 </head>
17
63708ff5 18 <body style="margin: 0px;">
91308399 19 <div id="VNC_screen">
63708ff5 20 <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">
8db09746 21 <table border=0 width="100%"><tr>
63708ff5 22 <td><div id="VNC_status">Loading</div></td>
8db09746 23 <td width="1%"><div id="VNC_buttons">
63708ff5 24 <input type=button value="Send CtrlAltDel"
8db09746
JM
25 id="sendCtrlAltDelButton">
26 </div></td>
63708ff5
JM
27 </tr></table>
28 </div>
91308399
JM
29 <canvas id="VNC_canvas" width="640px" height="20px">
30 Canvas not supported.
31 </canvas>
32 </div>
91308399 33
8db09746
JM
34 <script>
35 /*jslint white: false */
36 /*global window, $, Util, RFB, */
37 "use strict";
38
39 var rfb;
40
91308399 41 function setPassword() {
8db09746 42 rfb.sendPassword($('password_input').value);
91308399
JM
43 return false;
44 }
63708ff5 45 function sendCtrlAltDel() {
8db09746 46 rfb.sendCtrlAltDel();
a8edf9d8 47 return false;
63708ff5 48 }
8db09746
JM
49 function updateState(rfb, state, oldstate, msg) {
50 var s, sb, cad, klass;
91308399 51 s = $('VNC_status');
63708ff5 52 sb = $('VNC_status_bar');
160fabf6 53 cad = $('sendCtrlAltDelButton');
91308399 54 switch (state) {
f00b1e37
JM
55 case 'failed':
56 case 'fatal':
57 klass = "VNC_status_error";
58 break;
59 case 'normal':
60 klass = "VNC_status_normal";
61 break;
62 case 'disconnected':
63 case 'loaded':
64 klass = "VNC_status_normal";
65 break;
66 case 'password':
67 msg = '<form onsubmit="return setPassword();"';
68 msg += ' style="margin-bottom: 0px">';
69 msg += 'Password Required: ';
70 msg += '<input type=password size=10 id="password_input" class="VNC_status">';
8db09746
JM
71 msg += '<\/form>';
72 klass = "VNC_status_warn";
73 break;
f00b1e37
JM
74 default:
75 klass = "VNC_status_warn";
91308399
JM
76 }
77
160fabf6
JM
78 if (state === "normal") { cad.disabled = false; }
79 else { cad.disabled = true; }
80
91308399 81 if (typeof(msg) !== 'undefined') {
63708ff5 82 sb.setAttribute("class", klass);
91308399
JM
83 s.innerHTML = msg;
84 }
91308399
JM
85 }
86
87 window.onload = function () {
da6dd893 88 var host, port, password;
91308399 89
8db09746
JM
90 $('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
91
a8edf9d8
JM
92 host = Util.getQueryVar('host', null);
93 port = Util.getQueryVar('port', null);
94 password = Util.getQueryVar('password', '');
91308399
JM
95 if ((!host) || (!port)) {
96 updateState('failed',
97 "Must specify host and port in URL");
98 return;
99 }
100
673118fb 101 rfb = new RFB({'encrypt': Util.getQueryVar('encrypt', false),
8db09746
JM
102 'true_color': Util.getQueryVar('true_color', true),
103 'local_cursor': Util.getQueryVar('cursor', true),
104 'updateState': updateState});
105 rfb.connect(host, port, password);
106 };
107 </script>
da6dd893 108
8db09746 109 </body>
91308399
JM
110</html>
111