mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
Include status in title.
This commit is contained in:
@@ -372,8 +372,31 @@ var GuacamoleUI = {
|
|||||||
// Tie UI events / behavior to a specific Guacamole client
|
// Tie UI events / behavior to a specific Guacamole client
|
||||||
GuacamoleUI.attach = function(guac) {
|
GuacamoleUI.attach = function(guac) {
|
||||||
|
|
||||||
|
var title_prefix = null;
|
||||||
|
var connection_name = null
|
||||||
|
|
||||||
var guac_display = guac.getDisplay();
|
var guac_display = guac.getDisplay();
|
||||||
|
|
||||||
|
// Set document title appropriately, based on prefix and connection name
|
||||||
|
function updateTitle() {
|
||||||
|
|
||||||
|
// Use title prefix if present
|
||||||
|
if (title_prefix) {
|
||||||
|
|
||||||
|
document.title = title_prefix;
|
||||||
|
|
||||||
|
// Include connection name, if present
|
||||||
|
if (connection_name)
|
||||||
|
document.title += " " + connection_name;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, just set to connection name
|
||||||
|
else if (connection_name)
|
||||||
|
document.title = connection_name;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// When mouse enters display, start detection of intent to close menu
|
// When mouse enters display, start detection of intent to close menu
|
||||||
guac_display.addEventListener('mouseover', GuacamoleUI.startMenuCloseDetect, true);
|
guac_display.addEventListener('mouseover', GuacamoleUI.startMenuCloseDetect, true);
|
||||||
|
|
||||||
@@ -458,22 +481,26 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
|
|
||||||
// Handle client state change
|
// Handle client state change
|
||||||
guac.onstatechange = function(clientState) {
|
guac.onstatechange = function(clientState) {
|
||||||
|
|
||||||
switch (clientState) {
|
switch (clientState) {
|
||||||
|
|
||||||
// Idle
|
// Idle
|
||||||
case 0:
|
case 0:
|
||||||
GuacamoleUI.showStatus("Idle.");
|
GuacamoleUI.showStatus("Idle.");
|
||||||
|
title_prefix = "[Idle]";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Connecting
|
// Connecting
|
||||||
case 1:
|
case 1:
|
||||||
GuacamoleUI.shadeMenu();
|
GuacamoleUI.shadeMenu();
|
||||||
GuacamoleUI.showStatus("Connecting...");
|
GuacamoleUI.showStatus("Connecting...");
|
||||||
|
title_prefix = "[Connecting...]";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Connected + waiting
|
// Connected + waiting
|
||||||
case 2:
|
case 2:
|
||||||
GuacamoleUI.showStatus("Connected, waiting for first update...");
|
GuacamoleUI.showStatus("Connected, waiting for first update...");
|
||||||
|
title_prefix = "[Waiting...]";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Connected
|
// Connected
|
||||||
@@ -484,16 +511,20 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
GuacamoleUI.display.className.replace(/guac-loading/, '');
|
GuacamoleUI.display.className.replace(/guac-loading/, '');
|
||||||
|
|
||||||
GuacamoleUI.menu.className = "connected";
|
GuacamoleUI.menu.className = "connected";
|
||||||
|
|
||||||
|
title_prefix = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Disconnecting
|
// Disconnecting
|
||||||
case 4:
|
case 4:
|
||||||
GuacamoleUI.showStatus("Disconnecting...");
|
GuacamoleUI.showStatus("Disconnecting...");
|
||||||
|
title_prefix = "[Disconnecting...]";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Disconnected
|
// Disconnected
|
||||||
case 5:
|
case 5:
|
||||||
GuacamoleUI.showStatus("Disconnected.");
|
GuacamoleUI.showStatus("Disconnected.");
|
||||||
|
title_prefix = "[Disconnected]";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Unknown status code
|
// Unknown status code
|
||||||
@@ -501,11 +532,14 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
GuacamoleUI.showStatus("[UNKNOWN STATUS]");
|
GuacamoleUI.showStatus("[UNKNOWN STATUS]");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTitle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Name instruction handler
|
// Name instruction handler
|
||||||
guac.onname = function(name) {
|
guac.onname = function(name) {
|
||||||
document.title = name;
|
connection_name = name;
|
||||||
|
updateTitle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Error handler
|
// Error handler
|
||||||
|
Reference in New Issue
Block a user