]>
Commit | Line | Data |
---|---|---|
1 | <!DOCTYPE html> | |
2 | <html> | |
3 | <head> | |
4 | ||
5 | <!-- | |
6 | noVNC example: simple example using default UI | |
7 | Copyright (C) 2012 Joel Martin | |
8 | Copyright (C) 2013 Samuel Mannehed for Cendio AB | |
9 | noVNC is licensed under the MPL 2.0 (see LICENSE.txt) | |
10 | This file is licensed under the 2-Clause BSD license (see LICENSE.txt). | |
11 | ||
12 | Connect parameters are provided in query string: | |
13 | http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1 | |
14 | --> | |
15 | <title>noVNC</title> | |
16 | ||
17 | <meta charset="utf-8"> | |
18 | ||
19 | <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame | |
20 | Remove this if you use the .htaccess --> | |
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 | --> | |
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 | --> | |
43 | <script src="include/util.js"></script> | |
44 | </head> | |
45 | ||
46 | <body style="margin: 0px;"> | |
47 | <div id="noVNC_screen"> | |
48 | <div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;"> | |
49 | <table border=0 width="100%"><tr> | |
50 | <td><div id="noVNC_status" style="position: relative; height: auto;"> | |
51 | Loading | |
52 | </div></td> | |
53 | <td width="1%"><div id="noVNC_buttons"> | |
54 | <input type=button value="Send CtrlAltDel" | |
55 | id="sendCtrlAltDelButton"> | |
56 | <span id="noVNC_xvp_buttons"> | |
57 | <input type=button value="Shutdown" | |
58 | id="xvpShutdownButton"> | |
59 | <input type=button value="Reboot" | |
60 | id="xvpRebootButton"> | |
61 | <input type=button value="Reset" | |
62 | id="xvpResetButton"> | |
63 | </span> | |
64 | </div></td> | |
65 | </tr></table> | |
66 | </div> | |
67 | <canvas id="noVNC_canvas" width="640px" height="20px"> | |
68 | Canvas not supported. | |
69 | </canvas> | |
70 | </div> | |
71 | ||
72 | <script> | |
73 | /*jslint white: false */ | |
74 | /*global window, $, Util, RFB, */ | |
75 | "use strict"; | |
76 | ||
77 | // Load supporting scripts | |
78 | Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js", | |
79 | "keysymdef.js", "keyboard.js", "input.js", "display.js", | |
80 | "jsunzip.js", "rfb.js", "keysym.js"]); | |
81 | ||
82 | var rfb; | |
83 | ||
84 | function passwordRequired(rfb) { | |
85 | var msg; | |
86 | msg = '<form onsubmit="return setPassword();"'; | |
87 | msg += ' style="margin-bottom: 0px">'; | |
88 | msg += 'Password Required: '; | |
89 | msg += '<input type=password size=10 id="password_input" class="noVNC_status">'; | |
90 | msg += '<\/form>'; | |
91 | $D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn"); | |
92 | $D('noVNC_status').innerHTML = msg; | |
93 | } | |
94 | function setPassword() { | |
95 | rfb.sendPassword($D('password_input').value); | |
96 | return false; | |
97 | } | |
98 | function sendCtrlAltDel() { | |
99 | rfb.sendCtrlAltDel(); | |
100 | return false; | |
101 | } | |
102 | function xvpShutdown() { | |
103 | rfb.xvpShutdown(); | |
104 | return false; | |
105 | } | |
106 | function xvpReboot() { | |
107 | rfb.xvpReboot(); | |
108 | return false; | |
109 | } | |
110 | function xvpReset() { | |
111 | rfb.xvpReset(); | |
112 | return false; | |
113 | } | |
114 | function updateState(rfb, state, oldstate, msg) { | |
115 | var s, sb, cad, level; | |
116 | s = $D('noVNC_status'); | |
117 | sb = $D('noVNC_status_bar'); | |
118 | cad = $D('sendCtrlAltDelButton'); | |
119 | switch (state) { | |
120 | case 'failed': level = "error"; break; | |
121 | case 'fatal': level = "error"; break; | |
122 | case 'normal': level = "normal"; break; | |
123 | case 'disconnected': level = "normal"; break; | |
124 | case 'loaded': level = "normal"; break; | |
125 | default: level = "warn"; break; | |
126 | } | |
127 | ||
128 | if (state === "normal") { | |
129 | cad.disabled = false; | |
130 | } else { | |
131 | cad.disabled = true; | |
132 | xvpInit(0); | |
133 | } | |
134 | ||
135 | if (typeof(msg) !== 'undefined') { | |
136 | sb.setAttribute("class", "noVNC_status_" + level); | |
137 | s.innerHTML = msg; | |
138 | } | |
139 | } | |
140 | ||
141 | function xvpInit(ver) { | |
142 | var xvpbuttons; | |
143 | xvpbuttons = $D('noVNC_xvp_buttons'); | |
144 | if (ver >= 1) { | |
145 | xvpbuttons.style.display = 'inline'; | |
146 | } else { | |
147 | xvpbuttons.style.display = 'none'; | |
148 | } | |
149 | } | |
150 | ||
151 | window.onscriptsload = function () { | |
152 | var host, port, password, path, token; | |
153 | ||
154 | $D('sendCtrlAltDelButton').style.display = "inline"; | |
155 | $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; | |
156 | $D('xvpShutdownButton').onclick = xvpShutdown; | |
157 | $D('xvpRebootButton').onclick = xvpReboot; | |
158 | $D('xvpResetButton').onclick = xvpReset; | |
159 | ||
160 | WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn')); | |
161 | document.title = unescape(WebUtil.getQueryVar('title', 'noVNC')); | |
162 | // By default, use the host and port of server that served this file | |
163 | host = WebUtil.getQueryVar('host', window.location.hostname); | |
164 | port = WebUtil.getQueryVar('port', window.location.port); | |
165 | ||
166 | // if port == 80 (or 443) then it won't be present and should be | |
167 | // set manually | |
168 | if (!port) { | |
169 | if (window.location.protocol.substring(0,5) == 'https') { | |
170 | port = 443; | |
171 | } | |
172 | else if (window.location.protocol.substring(0,4) == 'http') { | |
173 | port = 80; | |
174 | } | |
175 | } | |
176 | ||
177 | // If a token variable is passed in, set the parameter in a cookie. | |
178 | // This is used by nova-novncproxy. | |
179 | token = WebUtil.getQueryVar('token', null); | |
180 | if (token) { | |
181 | WebUtil.createCookie('token', token, 1) | |
182 | } | |
183 | ||
184 | password = WebUtil.getQueryVar('password', ''); | |
185 | path = WebUtil.getQueryVar('path', 'websockify'); | |
186 | ||
187 | if ((!host) || (!port)) { | |
188 | updateState('failed', | |
189 | "Must specify host and port in URL"); | |
190 | return; | |
191 | } | |
192 | ||
193 | rfb = new RFB({'target': $D('noVNC_canvas'), | |
194 | 'encrypt': WebUtil.getQueryVar('encrypt', | |
195 | (window.location.protocol === "https:")), | |
196 | 'repeaterID': WebUtil.getQueryVar('repeaterID', ''), | |
197 | 'true_color': WebUtil.getQueryVar('true_color', true), | |
198 | 'local_cursor': WebUtil.getQueryVar('cursor', true), | |
199 | 'shared': WebUtil.getQueryVar('shared', true), | |
200 | 'view_only': WebUtil.getQueryVar('view_only', false), | |
201 | 'onUpdateState': updateState, | |
202 | 'onXvpInit': xvpInit, | |
203 | 'onPasswordRequired': passwordRequired}); | |
204 | rfb.connect(host, port, password, path); | |
205 | }; | |
206 | </script> | |
207 | ||
208 | </body> | |
209 | </html> |