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