]>
Commit | Line | Data |
---|---|---|
40f281eb | 1 | <!DOCTYPE html> |
91308399 | 2 | <html> |
e84101b3 PÅ |
3 | <head> |
4 | ||
d595e656 | 5 | <!-- |
d58f8b51 JM |
6 | noVNC example: simple example using default UI |
7 | Copyright (C) 2012 Joel Martin | |
1d728ace | 8 | noVNC is licensed under the MPL 2.0 (see LICENSE.txt) |
d58f8b51 | 9 | This file is licensed under the 2-Clause BSD license (see LICENSE.txt). |
d595e656 JM |
10 | |
11 | Connect parameters are provided in query string: | |
12 | http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1 | |
13 | --> | |
e84101b3 PÅ |
14 | <title>noVNC</title> |
15 | ||
33f5d3bd PÅ |
16 | <meta charset="utf-8"> |
17 | ||
e84101b3 PÅ |
18 | <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame |
19 | Remove this if you use the .htaccess --> | |
33f5d3bd PÅ |
20 | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
21 | ||
22 | <!-- Apple iOS Safari settings --> | |
23 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
24 | <meta name="apple-mobile-web-app-capable" content="yes" /> | |
25 | <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> | |
26 | <!-- App Start Icon --> | |
27 | <link rel="apple-touch-startup-image" href="images/screen_320x460.png" /> | |
28 | <!-- For iOS devices set the icon to use if user bookmarks app on their homescreen --> | |
29 | <link rel="apple-touch-icon" href="images/screen_57x57.png"> | |
30 | <!-- | |
31 | <link rel="apple-touch-icon-precomposed" href="images/screen_57x57.png" /> | |
32 | --> | |
e84101b3 PÅ |
33 | |
34 | ||
35 | <!-- Stylesheets --> | |
36 | <link rel="stylesheet" href="include/base.css" title="plain"> | |
37 | ||
38 | <!-- | |
39 | <script type='text/javascript' | |
40 | src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> | |
41 | --> | |
6f4b1e40 | 42 | <script src="include/util.js"></script> |
e84101b3 | 43 | </head> |
91308399 | 44 | |
e84101b3 PÅ |
45 | <body style="margin: 0px;"> |
46 | <div id="noVNC_screen"> | |
a7f55899 | 47 | <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;"> |
8db09746 | 48 | <table border=0 width="100%"><tr> |
a7f55899 JM |
49 | <td><div id="noVNC_status">Loading</div></td> |
50 | <td width="1%"><div id="noVNC_buttons"> | |
63708ff5 | 51 | <input type=button value="Send CtrlAltDel" |
8db09746 JM |
52 | id="sendCtrlAltDelButton"> |
53 | </div></td> | |
63708ff5 JM |
54 | </tr></table> |
55 | </div> | |
a7f55899 | 56 | <canvas id="noVNC_canvas" width="640px" height="20px"> |
91308399 JM |
57 | Canvas not supported. |
58 | </canvas> | |
59 | </div> | |
91308399 | 60 | |
8db09746 JM |
61 | <script> |
62 | /*jslint white: false */ | |
63 | /*global window, $, Util, RFB, */ | |
64 | "use strict"; | |
65 | ||
6f4b1e40 JM |
66 | // Load supporting scripts |
67 | Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js", | |
68 | "input.js", "display.js", "jsunzip.js", "rfb.js"]); | |
69 | ||
8db09746 JM |
70 | var rfb; |
71 | ||
d890e864 JM |
72 | function passwordRequired(rfb) { |
73 | var msg; | |
74 | msg = '<form onsubmit="return setPassword();"'; | |
75 | msg += ' style="margin-bottom: 0px">'; | |
76 | msg += 'Password Required: '; | |
a7f55899 | 77 | msg += '<input type=password size=10 id="password_input" class="noVNC_status">'; |
d890e864 | 78 | msg += '<\/form>'; |
a7f55899 JM |
79 | $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn"); |
80 | $D('noVNC_status').innerHTML = msg; | |
d890e864 | 81 | } |
91308399 | 82 | function setPassword() { |
e4671910 | 83 | rfb.sendPassword($D('password_input').value); |
91308399 JM |
84 | return false; |
85 | } | |
63708ff5 | 86 | function sendCtrlAltDel() { |
8db09746 | 87 | rfb.sendCtrlAltDel(); |
a8edf9d8 | 88 | return false; |
63708ff5 | 89 | } |
8db09746 | 90 | function updateState(rfb, state, oldstate, msg) { |
d890e864 | 91 | var s, sb, cad, level; |
a7f55899 JM |
92 | s = $D('noVNC_status'); |
93 | sb = $D('noVNC_status_bar'); | |
e4671910 | 94 | cad = $D('sendCtrlAltDelButton'); |
91308399 | 95 | switch (state) { |
d890e864 JM |
96 | case 'failed': level = "error"; break; |
97 | case 'fatal': level = "error"; break; | |
98 | case 'normal': level = "normal"; break; | |
99 | case 'disconnected': level = "normal"; break; | |
100 | case 'loaded': level = "normal"; break; | |
101 | default: level = "warn"; break; | |
91308399 JM |
102 | } |
103 | ||
160fabf6 JM |
104 | if (state === "normal") { cad.disabled = false; } |
105 | else { cad.disabled = true; } | |
106 | ||
91308399 | 107 | if (typeof(msg) !== 'undefined') { |
a7f55899 | 108 | sb.setAttribute("class", "noVNC_status_" + level); |
91308399 JM |
109 | s.innerHTML = msg; |
110 | } | |
91308399 JM |
111 | } |
112 | ||
6f4b1e40 | 113 | window.onscriptsload = function () { |
9ebc84f2 | 114 | var host, port, password, path, token; |
91308399 | 115 | |
a7f55899 | 116 | $D('sendCtrlAltDelButton').style.display = "inline"; |
e4671910 | 117 | $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; |
8db09746 | 118 | |
2cde6e43 | 119 | WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn')); |
2270c7b5 | 120 | document.title = unescape(WebUtil.getQueryVar('title', 'noVNC')); |
bd96e919 JM |
121 | // By default, use the host and port of server that served this file |
122 | host = WebUtil.getQueryVar('host', window.location.hostname); | |
123 | port = WebUtil.getQueryVar('port', window.location.port); | |
0139b256 | 124 | |
e83b9e03 WR |
125 | // if port == 80 (or 443) then it won't be present and should be |
126 | // set manually | |
127 | if (!port) { | |
128 | if (window.location.protocol.substring(0,4) == 'http') { | |
129 | port = 80; | |
130 | } | |
131 | else if (window.location.protocol.substring(0,5) == 'https') { | |
132 | port = 443; | |
133 | } | |
134 | } | |
135 | ||
0139b256 AY |
136 | // If a token variable is passed in, set the parameter in a cookie. |
137 | // This is used by nova-novncproxy. | |
4c75210a | 138 | token = WebUtil.getQueryVar('token', null); |
0139b256 | 139 | if (token) { |
0139b256 AY |
140 | WebUtil.createCookie('token', token, 1) |
141 | } | |
142 | ||
8d5d2c82 | 143 | password = WebUtil.getQueryVar('password', ''); |
523cc4d6 | 144 | path = WebUtil.getQueryVar('path', 'websockify'); |
b50f3406 | 145 | |
91308399 JM |
146 | if ((!host) || (!port)) { |
147 | updateState('failed', | |
148 | "Must specify host and port in URL"); | |
149 | return; | |
150 | } | |
151 | ||
a7f55899 | 152 | rfb = new RFB({'target': $D('noVNC_canvas'), |
1af3e54b JM |
153 | 'encrypt': WebUtil.getQueryVar('encrypt', |
154 | (window.location.protocol === "https:")), | |
9ebc84f2 | 155 | 'repeaterID': WebUtil.getQueryVar('repeaterID', ''), |
f1a9971c JM |
156 | 'true_color': WebUtil.getQueryVar('true_color', true), |
157 | 'local_cursor': WebUtil.getQueryVar('cursor', true), | |
158 | 'shared': WebUtil.getQueryVar('shared', true), | |
06a9ef0c | 159 | 'view_only': WebUtil.getQueryVar('view_only', false), |
d890e864 JM |
160 | 'updateState': updateState, |
161 | 'onPasswordRequired': passwordRequired}); | |
9ebc84f2 | 162 | rfb.connect(host, port, password, path); |
8db09746 JM |
163 | }; |
164 | </script> | |
da6dd893 | 165 | |
8db09746 | 166 | </body> |
91308399 | 167 | </html> |