|
@@ -1,6 +1,7 @@
|
|
/*
|
|
/*
|
|
* noVNC: HTML5 VNC client
|
|
* noVNC: HTML5 VNC client
|
|
* Copyright (C) 2012 Joel Martin
|
|
* Copyright (C) 2012 Joel Martin
|
|
|
|
+ * Copyright (C) 2013 Samuel Mannehed for Cendio AB
|
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
*
|
|
*
|
|
* See README.md for usage and integration instructions.
|
|
* See README.md for usage and integration instructions.
|
|
@@ -20,6 +21,7 @@ var UI = {
|
|
rfb_state : 'loaded',
|
|
rfb_state : 'loaded',
|
|
settingsOpen : false,
|
|
settingsOpen : false,
|
|
connSettingsOpen : false,
|
|
connSettingsOpen : false,
|
|
|
|
+popupStatusOpen : false,
|
|
clipboardOpen: false,
|
|
clipboardOpen: false,
|
|
keyboardVisible: false,
|
|
keyboardVisible: false,
|
|
|
|
|
|
@@ -82,7 +84,8 @@ start: function(callback) {
|
|
|
|
|
|
UI.rfb = RFB({'target': $D('noVNC_canvas'),
|
|
UI.rfb = RFB({'target': $D('noVNC_canvas'),
|
|
'onUpdateState': UI.updateState,
|
|
'onUpdateState': UI.updateState,
|
|
- 'onClipboard': UI.clipReceive});
|
|
|
|
|
|
+ 'onClipboard': UI.clipReceive,
|
|
|
|
+ 'onDesktopName': UI.updateDocumentTitle});
|
|
UI.updateVisualState();
|
|
UI.updateVisualState();
|
|
|
|
|
|
// Unfocus clipboard when over the VNC area
|
|
// Unfocus clipboard when over the VNC area
|
|
@@ -156,6 +159,8 @@ addMouseHandlers: function() {
|
|
$D("keyboardinput").onblur = UI.keyInputBlur;
|
|
$D("keyboardinput").onblur = UI.keyInputBlur;
|
|
|
|
|
|
$D("sendCtrlAltDelButton").onclick = UI.sendCtrlAltDel;
|
|
$D("sendCtrlAltDelButton").onclick = UI.sendCtrlAltDel;
|
|
|
|
+ $D("noVNC_status").onclick = UI.togglePopupStatusPanel;
|
|
|
|
+ $D("noVNC_popup_status_panel").onclick = UI.togglePopupStatusPanel;
|
|
$D("clipboardButton").onclick = UI.toggleClipboardPanel;
|
|
$D("clipboardButton").onclick = UI.toggleClipboardPanel;
|
|
$D("settingsButton").onclick = UI.toggleSettingsPanel;
|
|
$D("settingsButton").onclick = UI.toggleSettingsPanel;
|
|
$D("connectButton").onclick = UI.toggleConnectPanel;
|
|
$D("connectButton").onclick = UI.toggleConnectPanel;
|
|
@@ -257,20 +262,39 @@ forceSetting: function(name, val) {
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
+// Show the popup status panel
|
|
|
|
+togglePopupStatusPanel: function() {
|
|
|
|
+ var psp = $D('noVNC_popup_status_panel');
|
|
|
|
+ if (UI.popupStatusOpen === true) {
|
|
|
|
+ psp.style.display = "none";
|
|
|
|
+ UI.popupStatusOpen = false;
|
|
|
|
+ } else {
|
|
|
|
+ psp.innerHTML = $D('noVNC_status').innerHTML;
|
|
|
|
+ psp.style.display = "block";
|
|
|
|
+ psp.style.left = window.innerWidth/2 -
|
|
|
|
+ parseInt(window.getComputedStyle(psp, false).width)/2 -30 + "px";
|
|
|
|
+ UI.popupStatusOpen = true;
|
|
|
|
+ }
|
|
|
|
+},
|
|
|
|
+
|
|
// Show the clipboard panel
|
|
// Show the clipboard panel
|
|
toggleClipboardPanel: function() {
|
|
toggleClipboardPanel: function() {
|
|
// Close the description panel
|
|
// Close the description panel
|
|
$D('noVNC_description').style.display = "none";
|
|
$D('noVNC_description').style.display = "none";
|
|
- //Close settings if open
|
|
|
|
|
|
+ // Close settings if open
|
|
if (UI.settingsOpen === true) {
|
|
if (UI.settingsOpen === true) {
|
|
UI.settingsApply();
|
|
UI.settingsApply();
|
|
UI.closeSettingsMenu();
|
|
UI.closeSettingsMenu();
|
|
}
|
|
}
|
|
- //Close connection settings if open
|
|
|
|
|
|
+ // Close connection settings if open
|
|
if (UI.connSettingsOpen === true) {
|
|
if (UI.connSettingsOpen === true) {
|
|
UI.toggleConnectPanel();
|
|
UI.toggleConnectPanel();
|
|
}
|
|
}
|
|
- //Toggle Clipboard Panel
|
|
|
|
|
|
+ // Close popup status panel if open
|
|
|
|
+ if (UI.popupStatusOpen === true) {
|
|
|
|
+ UI.togglePopupStatusPanel();
|
|
|
|
+ }
|
|
|
|
+ // Toggle Clipboard Panel
|
|
if (UI.clipboardOpen === true) {
|
|
if (UI.clipboardOpen === true) {
|
|
$D('noVNC_clipboard').style.display = "none";
|
|
$D('noVNC_clipboard').style.display = "none";
|
|
$D('clipboardButton').className = "noVNC_status_button";
|
|
$D('clipboardButton').className = "noVNC_status_button";
|
|
@@ -286,17 +310,22 @@ toggleClipboardPanel: function() {
|
|
toggleConnectPanel: function() {
|
|
toggleConnectPanel: function() {
|
|
// Close the description panel
|
|
// Close the description panel
|
|
$D('noVNC_description').style.display = "none";
|
|
$D('noVNC_description').style.display = "none";
|
|
- //Close connection settings if open
|
|
|
|
|
|
+ // Close connection settings if open
|
|
if (UI.settingsOpen === true) {
|
|
if (UI.settingsOpen === true) {
|
|
UI.settingsApply();
|
|
UI.settingsApply();
|
|
UI.closeSettingsMenu();
|
|
UI.closeSettingsMenu();
|
|
$D('connectButton').className = "noVNC_status_button";
|
|
$D('connectButton').className = "noVNC_status_button";
|
|
}
|
|
}
|
|
|
|
+ // Close clipboard panel if open
|
|
if (UI.clipboardOpen === true) {
|
|
if (UI.clipboardOpen === true) {
|
|
UI.toggleClipboardPanel();
|
|
UI.toggleClipboardPanel();
|
|
}
|
|
}
|
|
|
|
+ // Close popup status panel if open
|
|
|
|
+ if (UI.popupStatusOpen === true) {
|
|
|
|
+ UI.togglePopupStatusPanel();
|
|
|
|
+ }
|
|
|
|
|
|
- //Toggle Connection Panel
|
|
|
|
|
|
+ // Toggle Connection Panel
|
|
if (UI.connSettingsOpen === true) {
|
|
if (UI.connSettingsOpen === true) {
|
|
$D('noVNC_controls').style.display = "none";
|
|
$D('noVNC_controls').style.display = "none";
|
|
$D('connectButton').className = "noVNC_status_button";
|
|
$D('connectButton').className = "noVNC_status_button";
|
|
@@ -347,13 +376,18 @@ toggleSettingsPanel: function() {
|
|
openSettingsMenu: function() {
|
|
openSettingsMenu: function() {
|
|
// Close the description panel
|
|
// Close the description panel
|
|
$D('noVNC_description').style.display = "none";
|
|
$D('noVNC_description').style.display = "none";
|
|
|
|
+ // Close clipboard panel if open
|
|
if (UI.clipboardOpen === true) {
|
|
if (UI.clipboardOpen === true) {
|
|
UI.toggleClipboardPanel();
|
|
UI.toggleClipboardPanel();
|
|
}
|
|
}
|
|
- //Close connection settings if open
|
|
|
|
|
|
+ // Close connection settings if open
|
|
if (UI.connSettingsOpen === true) {
|
|
if (UI.connSettingsOpen === true) {
|
|
UI.toggleConnectPanel();
|
|
UI.toggleConnectPanel();
|
|
}
|
|
}
|
|
|
|
+ // Close popup status panel if open
|
|
|
|
+ if (UI.popupStatusOpen === true) {
|
|
|
|
+ UI.togglePopupStatusPanel();
|
|
|
|
+ }
|
|
$D('noVNC_settings').style.display = "block";
|
|
$D('noVNC_settings').style.display = "block";
|
|
$D('settingsButton').className = "noVNC_status_button_selected";
|
|
$D('settingsButton').className = "noVNC_status_button_selected";
|
|
UI.settingsOpen = true;
|
|
UI.settingsOpen = true;
|
|
@@ -437,8 +471,6 @@ setMouseButton: function(num) {
|
|
updateState: function(rfb, state, oldstate, msg) {
|
|
updateState: function(rfb, state, oldstate, msg) {
|
|
var s, sb, c, d, cad, vd, klass;
|
|
var s, sb, c, d, cad, vd, klass;
|
|
UI.rfb_state = state;
|
|
UI.rfb_state = state;
|
|
- s = $D('noVNC_status');
|
|
|
|
- sb = $D('noVNC_status_bar');
|
|
|
|
switch (state) {
|
|
switch (state) {
|
|
case 'failed':
|
|
case 'failed':
|
|
case 'fatal':
|
|
case 'fatal':
|
|
@@ -468,9 +500,8 @@ updateState: function(rfb, state, oldstate, msg) {
|
|
}
|
|
}
|
|
|
|
|
|
if (typeof(msg) !== 'undefined') {
|
|
if (typeof(msg) !== 'undefined') {
|
|
- s.setAttribute("class", klass);
|
|
|
|
- sb.setAttribute("class", klass);
|
|
|
|
- s.innerHTML = msg;
|
|
|
|
|
|
+ $D('noVNC-control-bar').setAttribute("class", klass);
|
|
|
|
+ $D('noVNC_status').innerHTML = msg;
|
|
}
|
|
}
|
|
|
|
|
|
UI.updateVisualState();
|
|
UI.updateVisualState();
|
|
@@ -530,6 +561,12 @@ updateVisualState: function() {
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
+// Display the desktop name in the document title
|
|
|
|
+updateDocumentTitle: function(rfb, name) {
|
|
|
|
+ document.title = name + " - noVNC";
|
|
|
|
+},
|
|
|
|
+
|
|
|
|
+
|
|
clipReceive: function(rfb, text) {
|
|
clipReceive: function(rfb, text) {
|
|
Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "...");
|
|
Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "...");
|
|
$D('noVNC_clipboard_text').value = text;
|
|
$D('noVNC_clipboard_text').value = text;
|