Move the connect and disconnect functions
This commit is contained in:
parent
e00698fef8
commit
ab81ddf5d4
171
include/ui.js
171
include/ui.js
|
@ -569,7 +569,91 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Toggle fullscreen mode
|
// Show the connection settings panel/menu
|
||||||
|
toggleConnectPanel: function() {
|
||||||
|
// Close the description panel
|
||||||
|
$D('noVNC_description').style.display = "none";
|
||||||
|
// Close connection settings if open
|
||||||
|
if (UI.settingsOpen === true) {
|
||||||
|
UI.settingsApply();
|
||||||
|
UI.closeSettingsMenu();
|
||||||
|
$D('connectButton').className = "noVNC_status_button";
|
||||||
|
}
|
||||||
|
// Close clipboard panel if open
|
||||||
|
if (UI.clipboardOpen === true) {
|
||||||
|
UI.toggleClipboardPanel();
|
||||||
|
}
|
||||||
|
// Close XVP panel if open
|
||||||
|
if (UI.xvpOpen === true) {
|
||||||
|
UI.toggleXvpPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle Connection Panel
|
||||||
|
if (UI.connSettingsOpen === true) {
|
||||||
|
$D('noVNC_controls').style.display = "none";
|
||||||
|
$D('connectButton').className = "noVNC_status_button";
|
||||||
|
UI.connSettingsOpen = false;
|
||||||
|
UI.saveSetting('host');
|
||||||
|
UI.saveSetting('port');
|
||||||
|
UI.saveSetting('token');
|
||||||
|
//UI.saveSetting('password');
|
||||||
|
} else {
|
||||||
|
$D('noVNC_controls').style.display = "block";
|
||||||
|
$D('connectButton').className = "noVNC_status_button_selected";
|
||||||
|
UI.connSettingsOpen = true;
|
||||||
|
$D('noVNC_host').focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
connect: function() {
|
||||||
|
UI.closeSettingsMenu();
|
||||||
|
UI.toggleConnectPanel();
|
||||||
|
|
||||||
|
var host = $D('noVNC_host').value;
|
||||||
|
var port = $D('noVNC_port').value;
|
||||||
|
var password = $D('noVNC_password').value;
|
||||||
|
var token = $D('noVNC_token').value;
|
||||||
|
var path = $D('noVNC_path').value;
|
||||||
|
|
||||||
|
//if token is in path then ignore the new token variable
|
||||||
|
if (token) {
|
||||||
|
path = WebUtil.injectParamIfMissing(path, "token", token);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!host) || (!port)) {
|
||||||
|
throw new Error("Must set host and port");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UI.initRFB()) return;
|
||||||
|
|
||||||
|
UI.rfb.set_encrypt(UI.getSetting('encrypt'));
|
||||||
|
UI.rfb.set_true_color(UI.getSetting('true_color'));
|
||||||
|
UI.rfb.set_local_cursor(UI.getSetting('cursor'));
|
||||||
|
UI.rfb.set_shared(UI.getSetting('shared'));
|
||||||
|
UI.rfb.set_view_only(UI.getSetting('view_only'));
|
||||||
|
UI.rfb.set_repeaterID(UI.getSetting('repeaterID'));
|
||||||
|
|
||||||
|
UI.rfb.connect(host, port, password, path);
|
||||||
|
|
||||||
|
//Close dialog.
|
||||||
|
setTimeout(UI.setBarPosition, 100);
|
||||||
|
$D('noVNC_logo').style.display = "none";
|
||||||
|
$D('noVNC_screen').style.display = "inline";
|
||||||
|
},
|
||||||
|
|
||||||
|
disconnect: function() {
|
||||||
|
UI.closeSettingsMenu();
|
||||||
|
UI.rfb.disconnect();
|
||||||
|
|
||||||
|
// Restore the callback used for initial resize
|
||||||
|
UI.rfb.set_onFBUComplete(UI.initialResize);
|
||||||
|
|
||||||
|
$D('noVNC_logo').style.display = "block";
|
||||||
|
$D('noVNC_screen').style.display = "none";
|
||||||
|
|
||||||
|
// Don't display the connection settings until we're actually disconnected
|
||||||
|
},
|
||||||
|
|
||||||
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
|
||||||
|
@ -610,42 +694,6 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Show the connection settings panel/menu
|
|
||||||
toggleConnectPanel: function() {
|
|
||||||
// Close the description panel
|
|
||||||
$D('noVNC_description').style.display = "none";
|
|
||||||
// Close connection settings if open
|
|
||||||
if (UI.settingsOpen === true) {
|
|
||||||
UI.settingsApply();
|
|
||||||
UI.closeSettingsMenu();
|
|
||||||
$D('connectButton').className = "noVNC_status_button";
|
|
||||||
}
|
|
||||||
// Close clipboard panel if open
|
|
||||||
if (UI.clipboardOpen === true) {
|
|
||||||
UI.toggleClipboardPanel();
|
|
||||||
}
|
|
||||||
// Close XVP panel if open
|
|
||||||
if (UI.xvpOpen === true) {
|
|
||||||
UI.toggleXvpPanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle Connection Panel
|
|
||||||
if (UI.connSettingsOpen === true) {
|
|
||||||
$D('noVNC_controls').style.display = "none";
|
|
||||||
$D('connectButton').className = "noVNC_status_button";
|
|
||||||
UI.connSettingsOpen = false;
|
|
||||||
UI.saveSetting('host');
|
|
||||||
UI.saveSetting('port');
|
|
||||||
UI.saveSetting('token');
|
|
||||||
//UI.saveSetting('password');
|
|
||||||
} else {
|
|
||||||
$D('noVNC_controls').style.display = "block";
|
|
||||||
$D('connectButton').className = "noVNC_status_button_selected";
|
|
||||||
UI.connSettingsOpen = true;
|
|
||||||
$D('noVNC_host').focus();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Save/apply settings when 'Apply' button is pressed
|
// Save/apply settings when 'Apply' button is pressed
|
||||||
settingsApply: function() {
|
settingsApply: function() {
|
||||||
//Util.Debug(">> settingsApply");
|
//Util.Debug(">> settingsApply");
|
||||||
|
@ -748,55 +796,6 @@ var UI;
|
||||||
Util.Debug("<< UI.clipReceive");
|
Util.Debug("<< UI.clipReceive");
|
||||||
},
|
},
|
||||||
|
|
||||||
connect: function() {
|
|
||||||
UI.closeSettingsMenu();
|
|
||||||
UI.toggleConnectPanel();
|
|
||||||
|
|
||||||
var host = $D('noVNC_host').value;
|
|
||||||
var port = $D('noVNC_port').value;
|
|
||||||
var password = $D('noVNC_password').value;
|
|
||||||
var token = $D('noVNC_token').value;
|
|
||||||
var path = $D('noVNC_path').value;
|
|
||||||
|
|
||||||
//if token is in path then ignore the new token variable
|
|
||||||
if (token) {
|
|
||||||
path = WebUtil.injectParamIfMissing(path, "token", token);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!host) || (!port)) {
|
|
||||||
throw new Error("Must set host and port");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!UI.initRFB()) return;
|
|
||||||
|
|
||||||
UI.rfb.set_encrypt(UI.getSetting('encrypt'));
|
|
||||||
UI.rfb.set_true_color(UI.getSetting('true_color'));
|
|
||||||
UI.rfb.set_local_cursor(UI.getSetting('cursor'));
|
|
||||||
UI.rfb.set_shared(UI.getSetting('shared'));
|
|
||||||
UI.rfb.set_view_only(UI.getSetting('view_only'));
|
|
||||||
UI.rfb.set_repeaterID(UI.getSetting('repeaterID'));
|
|
||||||
|
|
||||||
UI.rfb.connect(host, port, password, path);
|
|
||||||
|
|
||||||
//Close dialog.
|
|
||||||
setTimeout(UI.setBarPosition, 100);
|
|
||||||
$D('noVNC_logo').style.display = "none";
|
|
||||||
$D('noVNC_screen').style.display = "inline";
|
|
||||||
},
|
|
||||||
|
|
||||||
disconnect: function() {
|
|
||||||
UI.closeSettingsMenu();
|
|
||||||
UI.rfb.disconnect();
|
|
||||||
|
|
||||||
// Restore the callback used for initial resize
|
|
||||||
UI.rfb.set_onFBUComplete(UI.initialResize);
|
|
||||||
|
|
||||||
$D('noVNC_logo').style.display = "block";
|
|
||||||
$D('noVNC_screen').style.display = "none";
|
|
||||||
|
|
||||||
// Don't display the connection settings until we're actually disconnected
|
|
||||||
},
|
|
||||||
|
|
||||||
displayBlur: function() {
|
displayBlur: function() {
|
||||||
if (!UI.rfb) return;
|
if (!UI.rfb) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue