Files
noVNC/vnc_auto.html
T

136 lines
5.3 KiB
HTML
Raw Normal View History

2011-01-30 23:42:28 -06:00
<!DOCTYPE html>
<html>
2010-09-08 10:11:11 -05:00
<!--
noVNC example: simple example using default UI
Copyright (C) 2012 Joel Martin
noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
2010-09-08 10:11:11 -05:00
Connect parameters are provided in query string:
http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
-->
<head>
<title>noVNC</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
2011-09-27 12:49:50 -05:00
<link rel="stylesheet" href="include/base.css" title="plain">
<!--
<script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
-->
<script src="include/util.js"></script>
</head>
2011-09-27 12:49:50 -05:00
<body style="margin: 0px;">
<div id="noVNC_screen">
<div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
2010-08-02 17:07:27 -05:00
<table border=0 width="100%"><tr>
2011-09-27 12:49:50 -05:00
<td><div id="noVNC_status">Loading</div></td>
<td width="1%"><div id="noVNC_buttons">
2010-06-15 17:47:01 -05:00
<input type=button value="Send CtrlAltDel"
2010-08-02 17:07:27 -05:00
id="sendCtrlAltDelButton">
</div></td>
2010-06-15 17:47:01 -05:00
</tr></table>
</div>
2011-09-27 12:49:50 -05:00
<canvas id="noVNC_canvas" width="640px" height="20px">
Canvas not supported.
</canvas>
</div>
2010-08-02 17:07:27 -05:00
<script>
/*jslint white: false */
/*global window, $, Util, RFB, */
"use strict";
// Load supporting scripts
Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
"input.js", "display.js", "jsunzip.js", "rfb.js"]);
2010-08-02 17:07:27 -05:00
var rfb;
2011-05-11 15:55:44 -05:00
function passwordRequired(rfb) {
var msg;
msg = '<form onsubmit="return setPassword();"';
msg += ' style="margin-bottom: 0px">';
msg += 'Password Required: ';
2011-09-27 12:49:50 -05:00
msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
2011-05-11 15:55:44 -05:00
msg += '<\/form>';
2011-09-27 12:49:50 -05:00
$D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
$D('noVNC_status').innerHTML = msg;
2011-05-11 15:55:44 -05:00
}
function setPassword() {
rfb.sendPassword($D('password_input').value);
return false;
}
2010-06-15 17:47:01 -05:00
function sendCtrlAltDel() {
2010-08-02 17:07:27 -05:00
rfb.sendCtrlAltDel();
2010-07-22 11:33:21 -05:00
return false;
2010-06-15 17:47:01 -05:00
}
2010-08-02 17:07:27 -05:00
function updateState(rfb, state, oldstate, msg) {
2011-05-11 15:55:44 -05:00
var s, sb, cad, level;
2011-09-27 12:49:50 -05:00
s = $D('noVNC_status');
sb = $D('noVNC_status_bar');
cad = $D('sendCtrlAltDelButton');
switch (state) {
2011-05-11 15:55:44 -05:00
case 'failed': level = "error"; break;
case 'fatal': level = "error"; break;
case 'normal': level = "normal"; break;
case 'disconnected': level = "normal"; break;
case 'loaded': level = "normal"; break;
default: level = "warn"; break;
}
2010-06-15 17:56:38 -05:00
if (state === "normal") { cad.disabled = false; }
else { cad.disabled = true; }
if (typeof(msg) !== 'undefined') {
2011-09-27 12:49:50 -05:00
sb.setAttribute("class", "noVNC_status_" + level);
s.innerHTML = msg;
}
}
window.onscriptsload = function () {
var host, port, password, path, token;
2011-09-27 12:49:50 -05:00
$D('sendCtrlAltDelButton').style.display = "inline";
$D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
2010-08-02 17:07:27 -05:00
WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn'));
2011-06-26 00:36:27 -07:00
document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
// By default, use the host and port of server that served this file
host = WebUtil.getQueryVar('host', window.location.hostname);
port = WebUtil.getQueryVar('port', window.location.port);
2012-04-03 10:34:24 -07:00
// If a token variable is passed in, set the parameter in a cookie.
// This is used by nova-novncproxy.
2012-04-03 10:08:41 -07:00
token = WebUtil.getQueryVar('token', null);
2012-04-03 10:34:24 -07:00
if (token) {
WebUtil.createCookie('token', token, 1)
}
2010-09-30 03:11:23 +08:00
password = WebUtil.getQueryVar('password', '');
path = WebUtil.getQueryVar('path', 'websockify');
2012-06-23 14:22:47 -05:00
if ((!host) || (!port)) {
updateState('failed',
"Must specify host and port in URL");
return;
}
2011-09-27 12:49:50 -05:00
rfb = new RFB({'target': $D('noVNC_canvas'),
'encrypt': WebUtil.getQueryVar('encrypt',
(window.location.protocol === "https:")),
'repeaterID': WebUtil.getQueryVar('repeaterID', ''),
2010-10-24 18:34:50 -05:00
'true_color': WebUtil.getQueryVar('true_color', true),
'local_cursor': WebUtil.getQueryVar('cursor', true),
'shared': WebUtil.getQueryVar('shared', true),
2011-12-01 09:05:16 -06:00
'view_only': WebUtil.getQueryVar('view_only', false),
2011-05-11 15:55:44 -05:00
'updateState': updateState,
'onPasswordRequired': passwordRequired});
rfb.connect(host, port, password, path);
2010-08-02 17:07:27 -05:00
};
</script>
2010-08-02 17:07:27 -05:00
</body>
</html>