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