mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 22:21:22 +00:00
Clean up interface.js a bit.
This commit is contained in:
@@ -107,43 +107,30 @@ GuacamoleUI.toggleKeyboard = function() {
|
||||
|
||||
};
|
||||
|
||||
// Constant UI initialization and behavior
|
||||
(function() {
|
||||
// If Node.classList is supported, implement addClass/removeClass using that
|
||||
if (Node.classList) {
|
||||
|
||||
// Cache error image (might not be available when error occurs)
|
||||
var guacErrorImage = new Image();
|
||||
guacErrorImage.src = "images/noguacamole-logo-24.png";
|
||||
|
||||
// Function for adding a class to an element
|
||||
var addClass;
|
||||
|
||||
// Function for removing a class from an element
|
||||
var removeClass;
|
||||
|
||||
// If Node.classList is supported, implement addClass/removeClass using that
|
||||
if (Node.classList) {
|
||||
|
||||
addClass = function(element, classname) {
|
||||
GuacamoleUI.addClass = function(element, classname) {
|
||||
element.classList.add(classname);
|
||||
};
|
||||
|
||||
removeClass = function(element, classname) {
|
||||
GuacamoleUI.removeClass = function(element, classname) {
|
||||
element.classList.remove(classname);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, implement own
|
||||
else {
|
||||
// Otherwise, implement own
|
||||
else {
|
||||
|
||||
addClass = function(element, classname) {
|
||||
GuacamoleUI.addClass = function(element, classname) {
|
||||
|
||||
// Simply add new class
|
||||
element.className += " " + classname;
|
||||
|
||||
};
|
||||
|
||||
removeClass = function(element, classname) {
|
||||
GuacamoleUI.removeClass = function(element, classname) {
|
||||
|
||||
// Filter out classes with given name
|
||||
element.className = element.className.replace(/([^ ]+)[ ]*/g,
|
||||
@@ -161,56 +148,35 @@ GuacamoleUI.toggleKeyboard = function() {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GuacamoleUI.hideStatus = function() {
|
||||
removeClass(document.body, "guac-error");
|
||||
GuacamoleUI.hideStatus = function() {
|
||||
GuacamoleUI.removeClass(document.body, "guac-error");
|
||||
GuacamoleUI.containers.state.style.visibility = "hidden";
|
||||
GuacamoleUI.display.style.opacity = "1";
|
||||
};
|
||||
};
|
||||
|
||||
GuacamoleUI.showStatus = function(text) {
|
||||
removeClass(document.body, "guac-error");
|
||||
GuacamoleUI.showStatus = function(text) {
|
||||
GuacamoleUI.removeClass(document.body, "guac-error");
|
||||
GuacamoleUI.containers.state.style.visibility = "visible";
|
||||
GuacamoleUI.state.textContent = text;
|
||||
GuacamoleUI.display.style.opacity = "1";
|
||||
};
|
||||
};
|
||||
|
||||
GuacamoleUI.showError = function(error) {
|
||||
addClass(document.body, "guac-error");
|
||||
GuacamoleUI.showError = function(error) {
|
||||
GuacamoleUI.addClass(document.body, "guac-error");
|
||||
GuacamoleUI.state.textContent = error;
|
||||
GuacamoleUI.display.style.opacity = "0.1";
|
||||
};
|
||||
};
|
||||
|
||||
// Detect three-finger tap
|
||||
GuacamoleUI.display.addEventListener('touchstart', function(e) {
|
||||
|
||||
// If three touches, toggle keyboard
|
||||
if (e.touches.length == 3)
|
||||
GuacamoleUI.toggleKeyboard();
|
||||
|
||||
}, true);
|
||||
|
||||
function positionCentered(element) {
|
||||
element.style.left =
|
||||
((GuacamoleUI.viewport.offsetWidth - element.offsetWidth) / 2
|
||||
+ window.pageXOffset)
|
||||
+ "px";
|
||||
|
||||
element.style.top =
|
||||
((GuacamoleUI.viewport.offsetHeight - element.offsetHeight) / 2
|
||||
+ window.pageYOffset)
|
||||
+ "px";
|
||||
}
|
||||
|
||||
// Reconnect button
|
||||
GuacamoleUI.buttons.reconnect.onclick = function() {
|
||||
// Reconnect button
|
||||
GuacamoleUI.buttons.reconnect.onclick = function() {
|
||||
window.location.reload();
|
||||
};
|
||||
};
|
||||
|
||||
// Query audio support
|
||||
if (!GuacamoleUI.sessionState.getProperty("disable-sound"))
|
||||
// Query audio support
|
||||
if (!GuacamoleUI.sessionState.getProperty("disable-sound"))
|
||||
(function () {
|
||||
var probably_supported = [];
|
||||
var maybe_supported = [];
|
||||
@@ -244,8 +210,8 @@ GuacamoleUI.toggleKeyboard = function() {
|
||||
Array.prototype.push.apply(GuacamoleUI.supportedAudio, maybe_supported);
|
||||
})();
|
||||
|
||||
// Query video support
|
||||
(function () {
|
||||
// Query video support
|
||||
(function () {
|
||||
var probably_supported = [];
|
||||
var maybe_supported = [];
|
||||
|
||||
@@ -274,8 +240,6 @@ GuacamoleUI.toggleKeyboard = function() {
|
||||
|
||||
Array.prototype.push.apply(GuacamoleUI.supportedVideo, probably_supported);
|
||||
Array.prototype.push.apply(GuacamoleUI.supportedVideo, maybe_supported);
|
||||
})();
|
||||
|
||||
})();
|
||||
|
||||
// Tie UI events / behavior to a specific Guacamole client
|
||||
|
Reference in New Issue
Block a user