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