Merge pull request #950 from samhed/disconnectapi

Abstract information from RFB to the UI
This commit is contained in:
Samuel Mannehed
2017-11-17 11:01:11 +01:00
committed by GitHub
13 changed files with 506 additions and 474 deletions
+20 -42
View File
@@ -147,50 +147,27 @@
document.getElementById('noVNC_status_bar').className = "noVNC_status_" + level;
document.getElementById('noVNC_status').textContent = text;
}
function updateState(e) {
var cad = document.getElementById('sendCtrlAltDelButton');
switch (e.detail.state) {
case 'connecting':
status("Connecting", "normal");
break;
case 'connected':
doneInitialResize = false;
if (WebUtil.getConfigVar('encrypt',
(window.location.protocol === "https:"))) {
status("Connected (encrypted) to " +
desktopName, "normal");
} else {
status("Connected (unencrypted) to " +
desktopName, "normal");
}
break;
case 'disconnecting':
status("Disconnecting", "normal");
break;
case 'disconnected':
status("Disconnected", "normal");
break;
default:
status(e.detail.state, "warn");
break;
}
if (e.detail.state === 'connected') {
cad.disabled = false;
function connected(e) {
document.getElementById('sendCtrlAltDelButton').disabled = false;
doneInitialResize = false;
if (WebUtil.getConfigVar('encrypt',
(window.location.protocol === "https:"))) {
status("Connected (encrypted) to " + desktopName, "normal");
} else {
cad.disabled = true;
updatePowerButtons();
status("Connected (unencrypted) to " + desktopName, "normal");
}
}
}
function disconnect(e) {
if (typeof(e.detail.reason) !== 'undefined') {
status(e.detail.reason, "error");
function disconnected(e) {
document.getElementById('sendCtrlAltDelButton').disabled = true;
updatePowerButtons();
if (e.detail.clean) {
status("Disconnected", "normal");
} else {
status("Something went wrong, connection is closed", "error");
}
}
function notification(e) {
status(e.detail.message, e.detail.level);
}
window.onresize = function () {
// When the window has been resized, wait until the size remains
@@ -249,6 +226,8 @@
(function() {
status("Connecting", "normal");
if ((!host) || (!port)) {
status('Must specify host and port in URL', 'error');
}
@@ -272,10 +251,9 @@
{ repeaterID: WebUtil.getConfigVar('repeaterID', ''),
shared: WebUtil.getConfigVar('shared', true),
credentials: { password: password } });
rfb.viewOnly = WebUtil.getConfigVar('view_only', false);
rfb.addEventListener("notification", notification);
rfb.addEventListener("updatestate", updateState);
rfb.addEventListener("disconnect", disconnect);
rfb.viewOnly = WebUtil.getConfigVar('view_only', false);
rfb.addEventListener("connect", connected);
rfb.addEventListener("disconnect", disconnected);
rfb.addEventListener("capabilities", function () { updatePowerButtons(); initialResize(); });
rfb.addEventListener("credentialsrequired", credentials);
rfb.addEventListener("desktopname", updateDesktopName);