]>
Commit | Line | Data |
---|---|---|
40f281eb | 1 | <!DOCTYPE html> |
91308399 | 2 | <html> |
d595e656 JM |
3 | <!-- |
4 | noVNC Example: Automatically connect on page load. | |
d0c29bb6 | 5 | Copyright (C) 2011 Joel Martin |
5f409eee | 6 | Licensed under LGPL-3 (see LICENSE.txt) |
d595e656 JM |
7 | |
8 | Connect parameters are provided in query string: | |
9 | http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1 | |
10 | --> | |
91308399 | 11 | <head> |
e66f3f89 JM |
12 | <title>noVNC</title> |
13 | <meta http-equiv="X-UA-Compatible" content="chrome=1"> | |
a7f55899 | 14 | <link rel="stylesheet" href="include/base.css" title="plain"> |
a93c9555 JM |
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> | |
91308399 JM |
20 | </head> |
21 | ||
a7f55899 JM |
22 | <body style="margin: 0px;"> |
23 | <div id="noVNC_screen"> | |
24 | <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;"> | |
8db09746 | 25 | <table border=0 width="100%"><tr> |
a7f55899 JM |
26 | <td><div id="noVNC_status">Loading</div></td> |
27 | <td width="1%"><div id="noVNC_buttons"> | |
63708ff5 | 28 | <input type=button value="Send CtrlAltDel" |
8db09746 JM |
29 | id="sendCtrlAltDelButton"> |
30 | </div></td> | |
63708ff5 JM |
31 | </tr></table> |
32 | </div> | |
a7f55899 | 33 | <canvas id="noVNC_canvas" width="640px" height="20px"> |
91308399 JM |
34 | Canvas not supported. |
35 | </canvas> | |
36 | </div> | |
91308399 | 37 | |
8db09746 JM |
38 | <script> |
39 | /*jslint white: false */ | |
40 | /*global window, $, Util, RFB, */ | |
41 | "use strict"; | |
42 | ||
43 | var rfb; | |
44 | ||
d890e864 JM |
45 | function passwordRequired(rfb) { |
46 | var msg; | |
47 | msg = '<form onsubmit="return setPassword();"'; | |
48 | msg += ' style="margin-bottom: 0px">'; | |
49 | msg += 'Password Required: '; | |
a7f55899 | 50 | msg += '<input type=password size=10 id="password_input" class="noVNC_status">'; |
d890e864 | 51 | msg += '<\/form>'; |
a7f55899 JM |
52 | $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn"); |
53 | $D('noVNC_status').innerHTML = msg; | |
d890e864 | 54 | } |
91308399 | 55 | function setPassword() { |
e4671910 | 56 | rfb.sendPassword($D('password_input').value); |
91308399 JM |
57 | return false; |
58 | } | |
63708ff5 | 59 | function sendCtrlAltDel() { |
8db09746 | 60 | rfb.sendCtrlAltDel(); |
a8edf9d8 | 61 | return false; |
63708ff5 | 62 | } |
8db09746 | 63 | function updateState(rfb, state, oldstate, msg) { |
d890e864 | 64 | var s, sb, cad, level; |
a7f55899 JM |
65 | s = $D('noVNC_status'); |
66 | sb = $D('noVNC_status_bar'); | |
e4671910 | 67 | cad = $D('sendCtrlAltDelButton'); |
91308399 | 68 | switch (state) { |
d890e864 JM |
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; | |
91308399 JM |
75 | } |
76 | ||
160fabf6 JM |
77 | if (state === "normal") { cad.disabled = false; } |
78 | else { cad.disabled = true; } | |
79 | ||
91308399 | 80 | if (typeof(msg) !== 'undefined') { |
a7f55899 | 81 | sb.setAttribute("class", "noVNC_status_" + level); |
91308399 JM |
82 | s.innerHTML = msg; |
83 | } | |
91308399 JM |
84 | } |
85 | ||
86 | window.onload = function () { | |
9ebc84f2 | 87 | var host, port, password, path, token; |
91308399 | 88 | |
a7f55899 | 89 | $D('sendCtrlAltDelButton').style.display = "inline"; |
e4671910 | 90 | $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; |
8db09746 | 91 | |
2270c7b5 | 92 | document.title = unescape(WebUtil.getQueryVar('title', 'noVNC')); |
bd96e919 JM |
93 | // By default, use the host and port of server that served this file |
94 | host = WebUtil.getQueryVar('host', window.location.hostname); | |
95 | port = WebUtil.getQueryVar('port', window.location.port); | |
0139b256 AY |
96 | |
97 | // If a token variable is passed in, set the parameter in a cookie. | |
98 | // This is used by nova-novncproxy. | |
4c75210a | 99 | token = WebUtil.getQueryVar('token', null); |
0139b256 | 100 | if (token) { |
0139b256 AY |
101 | WebUtil.createCookie('token', token, 1) |
102 | } | |
103 | ||
8d5d2c82 | 104 | password = WebUtil.getQueryVar('password', ''); |
523cc4d6 | 105 | path = WebUtil.getQueryVar('path', 'websockify'); |
8d0c7fb5 | 106 | |
91308399 JM |
107 | if ((!host) || (!port)) { |
108 | updateState('failed', | |
109 | "Must specify host and port in URL"); | |
110 | return; | |
111 | } | |
112 | ||
a7f55899 | 113 | rfb = new RFB({'target': $D('noVNC_canvas'), |
1af3e54b JM |
114 | 'encrypt': WebUtil.getQueryVar('encrypt', |
115 | (window.location.protocol === "https:")), | |
9ebc84f2 | 116 | 'repeaterID': WebUtil.getQueryVar('repeaterID', ''), |
f1a9971c JM |
117 | 'true_color': WebUtil.getQueryVar('true_color', true), |
118 | 'local_cursor': WebUtil.getQueryVar('cursor', true), | |
119 | 'shared': WebUtil.getQueryVar('shared', true), | |
06a9ef0c | 120 | 'view_only': WebUtil.getQueryVar('view_only', false), |
d890e864 JM |
121 | 'updateState': updateState, |
122 | 'onPasswordRequired': passwordRequired}); | |
9ebc84f2 | 123 | rfb.connect(host, port, password, path); |
8db09746 JM |
124 | }; |
125 | </script> | |
da6dd893 | 126 | |
8db09746 | 127 | </body> |
91308399 JM |
128 | </html> |
129 |