Group together related functions and add dividers
Dividers between the different parts of the UI has been added in order to easier get an overview.
This commit is contained in:
parent
69e9dc0d55
commit
6f388df065
264
include/ui.js
264
include/ui.js
|
@ -245,6 +245,12 @@ var UI;
|
||||||
$D("noVNC_resize").onchange = UI.enableDisableViewClip;
|
$D("noVNC_resize").onchange = UI.enableDisableViewClip;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /INIT
|
||||||
|
* ==============
|
||||||
|
* VISUAL
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
updateState: function(rfb, state, oldstate, msg) {
|
updateState: function(rfb, state, oldstate, msg) {
|
||||||
UI.rfb_state = state;
|
UI.rfb_state = state;
|
||||||
var klass;
|
var klass;
|
||||||
|
@ -373,6 +379,12 @@ var UI;
|
||||||
$D('noVNC_popup_status').style.display = "none";
|
$D('noVNC_popup_status').style.display = "none";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /VISUAL
|
||||||
|
* ==============
|
||||||
|
* SETTINGS
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
// Initial page load read/initialization of settings
|
// Initial page load read/initialization of settings
|
||||||
initSetting: function(name, defVal) {
|
initSetting: function(name, defVal) {
|
||||||
// Check Query string followed by cookie
|
// Check Query string followed by cookie
|
||||||
|
@ -452,6 +464,37 @@ var UI;
|
||||||
return val;
|
return val;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Save/apply settings when 'Apply' button is pressed
|
||||||
|
settingsApply: function() {
|
||||||
|
//Util.Debug(">> settingsApply");
|
||||||
|
UI.saveSetting('encrypt');
|
||||||
|
UI.saveSetting('true_color');
|
||||||
|
if (Util.browserSupportsCursorURIs()) {
|
||||||
|
UI.saveSetting('cursor');
|
||||||
|
}
|
||||||
|
|
||||||
|
UI.saveSetting('resize');
|
||||||
|
|
||||||
|
if (UI.getSetting('resize') === 'downscale' || UI.getSetting('resize') === 'scale') {
|
||||||
|
UI.forceSetting('clip', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
UI.saveSetting('clip');
|
||||||
|
UI.saveSetting('shared');
|
||||||
|
UI.saveSetting('view_only');
|
||||||
|
UI.saveSetting('path');
|
||||||
|
UI.saveSetting('repeaterID');
|
||||||
|
UI.saveSetting('stylesheet');
|
||||||
|
UI.saveSetting('logging');
|
||||||
|
|
||||||
|
// Settings with immediate (non-connected related) effect
|
||||||
|
WebUtil.selectStylesheet(UI.getSetting('stylesheet'));
|
||||||
|
WebUtil.init_logging(UI.getSetting('logging'));
|
||||||
|
UI.setViewClip();
|
||||||
|
UI.updateViewDrag();
|
||||||
|
//Util.Debug("<< settingsApply");
|
||||||
|
},
|
||||||
|
|
||||||
// Open menu
|
// Open menu
|
||||||
openSettingsMenu: function() {
|
openSettingsMenu: function() {
|
||||||
// Close the description panel
|
// Close the description panel
|
||||||
|
@ -511,6 +554,12 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /SETTINGS
|
||||||
|
* ==============
|
||||||
|
* XVP
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
// Show the XVP panel
|
// Show the XVP panel
|
||||||
toggleXvpPanel: function() {
|
toggleXvpPanel: function() {
|
||||||
// Close the description panel
|
// Close the description panel
|
||||||
|
@ -553,6 +602,12 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /XVP
|
||||||
|
* ==============
|
||||||
|
* CLIPBOARD
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
// Show the clipboard panel
|
// Show the clipboard panel
|
||||||
toggleClipboardPanel: function() {
|
toggleClipboardPanel: function() {
|
||||||
// Close the description panel
|
// Close the description panel
|
||||||
|
@ -582,6 +637,30 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clipReceive: function(rfb, text) {
|
||||||
|
Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "...");
|
||||||
|
$D('noVNC_clipboard_text').value = text;
|
||||||
|
Util.Debug("<< UI.clipReceive");
|
||||||
|
},
|
||||||
|
|
||||||
|
clipClear: function() {
|
||||||
|
$D('noVNC_clipboard_text').value = "";
|
||||||
|
UI.rfb.clipboardPasteFrom("");
|
||||||
|
},
|
||||||
|
|
||||||
|
clipSend: function() {
|
||||||
|
var text = $D('noVNC_clipboard_text').value;
|
||||||
|
Util.Debug(">> UI.clipSend: " + text.substr(0,40) + "...");
|
||||||
|
UI.rfb.clipboardPasteFrom(text);
|
||||||
|
Util.Debug("<< UI.clipSend");
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /CLIPBOARD
|
||||||
|
* ==============
|
||||||
|
* CONNECTION
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
// Show the connection settings panel/menu
|
// Show the connection settings panel/menu
|
||||||
toggleConnectPanel: function() {
|
toggleConnectPanel: function() {
|
||||||
// Close the description panel
|
// Close the description panel
|
||||||
|
@ -667,6 +746,22 @@ var UI;
|
||||||
// Don't display the connection settings until we're actually disconnected
|
// Don't display the connection settings until we're actually disconnected
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setPassword: function() {
|
||||||
|
UI.rfb.sendPassword($D('noVNC_password').value);
|
||||||
|
//Reset connect button.
|
||||||
|
$D('noVNC_connect_button').value = "Connect";
|
||||||
|
$D('noVNC_connect_button').onclick = UI.connect;
|
||||||
|
//Hide connection panel.
|
||||||
|
UI.toggleConnectPanel();
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /CONNECTION
|
||||||
|
* ==============
|
||||||
|
* FULLSCREEN
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
toggleFullscreen: function() {
|
toggleFullscreen: function() {
|
||||||
if (document.fullscreenElement || // alternative standard method
|
if (document.fullscreenElement || // alternative standard method
|
||||||
document.mozFullScreenElement || // currently working methods
|
document.mozFullScreenElement || // currently working methods
|
||||||
|
@ -707,85 +802,11 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Save/apply settings when 'Apply' button is pressed
|
/* ------^-------
|
||||||
settingsApply: function() {
|
* /FULLSCREEN
|
||||||
//Util.Debug(">> settingsApply");
|
* ==============
|
||||||
UI.saveSetting('encrypt');
|
* RESIZE
|
||||||
UI.saveSetting('true_color');
|
* ------v------*/
|
||||||
if (Util.browserSupportsCursorURIs()) {
|
|
||||||
UI.saveSetting('cursor');
|
|
||||||
}
|
|
||||||
|
|
||||||
UI.saveSetting('resize');
|
|
||||||
|
|
||||||
if (UI.getSetting('resize') === 'downscale' || UI.getSetting('resize') === 'scale') {
|
|
||||||
UI.forceSetting('clip', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
UI.saveSetting('clip');
|
|
||||||
UI.saveSetting('shared');
|
|
||||||
UI.saveSetting('view_only');
|
|
||||||
UI.saveSetting('path');
|
|
||||||
UI.saveSetting('repeaterID');
|
|
||||||
UI.saveSetting('stylesheet');
|
|
||||||
UI.saveSetting('logging');
|
|
||||||
|
|
||||||
// Settings with immediate (non-connected related) effect
|
|
||||||
WebUtil.selectStylesheet(UI.getSetting('stylesheet'));
|
|
||||||
WebUtil.init_logging(UI.getSetting('logging'));
|
|
||||||
UI.setViewClip();
|
|
||||||
UI.updateViewDrag();
|
|
||||||
//Util.Debug("<< settingsApply");
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
setPassword: function() {
|
|
||||||
UI.rfb.sendPassword($D('noVNC_password').value);
|
|
||||||
//Reset connect button.
|
|
||||||
$D('noVNC_connect_button').value = "Connect";
|
|
||||||
$D('noVNC_connect_button').onclick = UI.connect;
|
|
||||||
//Hide connection panel.
|
|
||||||
UI.toggleConnectPanel();
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Display the desktop name in the document title
|
|
||||||
updateDocumentTitle: function(rfb, name) {
|
|
||||||
document.title = name + " - noVNC";
|
|
||||||
},
|
|
||||||
|
|
||||||
clipReceive: function(rfb, text) {
|
|
||||||
Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "...");
|
|
||||||
$D('noVNC_clipboard_text').value = text;
|
|
||||||
Util.Debug("<< UI.clipReceive");
|
|
||||||
},
|
|
||||||
|
|
||||||
displayBlur: function() {
|
|
||||||
if (!UI.rfb) return;
|
|
||||||
|
|
||||||
UI.rfb.get_keyboard().set_focused(false);
|
|
||||||
UI.rfb.get_mouse().set_focused(false);
|
|
||||||
},
|
|
||||||
|
|
||||||
displayFocus: function() {
|
|
||||||
if (!UI.rfb) return;
|
|
||||||
|
|
||||||
UI.rfb.get_keyboard().set_focused(true);
|
|
||||||
UI.rfb.get_mouse().set_focused(true);
|
|
||||||
},
|
|
||||||
|
|
||||||
clipClear: function() {
|
|
||||||
$D('noVNC_clipboard_text').value = "";
|
|
||||||
UI.rfb.clipboardPasteFrom("");
|
|
||||||
},
|
|
||||||
|
|
||||||
clipSend: function() {
|
|
||||||
var text = $D('noVNC_clipboard_text').value;
|
|
||||||
Util.Debug(">> UI.clipSend: " + text.substr(0,40) + "...");
|
|
||||||
UI.rfb.clipboardPasteFrom(text);
|
|
||||||
Util.Debug("<< UI.clipSend");
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
// Apply remote resizing or local scaling
|
// Apply remote resizing or local scaling
|
||||||
applyResizeMode: function() {
|
applyResizeMode: function() {
|
||||||
|
@ -861,6 +882,12 @@ var UI;
|
||||||
UI.rfb.set_onFBUComplete(function() { });
|
UI.rfb.set_onFBUComplete(function() { });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /RESIZE
|
||||||
|
* ==============
|
||||||
|
* CLIPPING
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
// Set and configure viewport clipping
|
// Set and configure viewport clipping
|
||||||
setViewClip: function(clip) {
|
setViewClip: function(clip) {
|
||||||
var display;
|
var display;
|
||||||
|
@ -947,6 +974,12 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /CLIPPING
|
||||||
|
* ==============
|
||||||
|
* VIEWDRAG
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
// Update the viewport drag state
|
// Update the viewport drag state
|
||||||
updateViewDrag: function(drag) {
|
updateViewDrag: function(drag) {
|
||||||
if (!UI.rfb) return;
|
if (!UI.rfb) return;
|
||||||
|
@ -1006,25 +1039,11 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setMouseButton: function(num) {
|
/* ------^-------
|
||||||
if (typeof num === 'undefined') {
|
* /VIEWDRAG
|
||||||
// Disable mouse buttons
|
* ==============
|
||||||
num = -1;
|
* KEYBOARD
|
||||||
}
|
* ------v------*/
|
||||||
if (UI.rfb) {
|
|
||||||
UI.rfb.get_mouse().set_touchButton(num);
|
|
||||||
}
|
|
||||||
|
|
||||||
var blist = [0, 1,2,4];
|
|
||||||
for (var b = 0; b < blist.length; b++) {
|
|
||||||
var button = $D('noVNC_mouse_button' + blist[b]);
|
|
||||||
if (blist[b] === num) {
|
|
||||||
button.style.display = "";
|
|
||||||
} else {
|
|
||||||
button.style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// On touch devices, show the OS keyboard
|
// On touch devices, show the OS keyboard
|
||||||
showKeyboard: function() {
|
showKeyboard: function() {
|
||||||
|
@ -1201,6 +1220,51 @@ var UI;
|
||||||
UI.rfb.sendCtrlAltDel();
|
UI.rfb.sendCtrlAltDel();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /KEYBOARD
|
||||||
|
* ==============
|
||||||
|
* MISC
|
||||||
|
* ------v------*/
|
||||||
|
|
||||||
|
setMouseButton: function(num) {
|
||||||
|
if (typeof num === 'undefined') {
|
||||||
|
// Disable mouse buttons
|
||||||
|
num = -1;
|
||||||
|
}
|
||||||
|
if (UI.rfb) {
|
||||||
|
UI.rfb.get_mouse().set_touchButton(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
var blist = [0, 1,2,4];
|
||||||
|
for (var b = 0; b < blist.length; b++) {
|
||||||
|
var button = $D('noVNC_mouse_button' + blist[b]);
|
||||||
|
if (blist[b] === num) {
|
||||||
|
button.style.display = "";
|
||||||
|
} else {
|
||||||
|
button.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
displayBlur: function() {
|
||||||
|
if (!UI.rfb) return;
|
||||||
|
|
||||||
|
UI.rfb.get_keyboard().set_focused(false);
|
||||||
|
UI.rfb.get_mouse().set_focused(false);
|
||||||
|
},
|
||||||
|
|
||||||
|
displayFocus: function() {
|
||||||
|
if (!UI.rfb) return;
|
||||||
|
|
||||||
|
UI.rfb.get_keyboard().set_focused(true);
|
||||||
|
UI.rfb.get_mouse().set_focused(true);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Display the desktop name in the document title
|
||||||
|
updateDocumentTitle: function(rfb, name) {
|
||||||
|
document.title = name + " - noVNC";
|
||||||
|
},
|
||||||
|
|
||||||
//Helper to add options to dropdown.
|
//Helper to add options to dropdown.
|
||||||
addOption: function(selectbox, text, value) {
|
addOption: function(selectbox, text, value) {
|
||||||
var optn = document.createElement("OPTION");
|
var optn = document.createElement("OPTION");
|
||||||
|
@ -1217,5 +1281,9 @@ var UI;
|
||||||
$D('noVNC-control-bar').style.width = vncwidth + 'px';
|
$D('noVNC-control-bar').style.width = vncwidth + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------^-------
|
||||||
|
* /MISC
|
||||||
|
* ==============
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue