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