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) {
+ element.classList.add(classname);
+ };
+
+ removeClass = function(element, classname) {
+ element.classList.remove(classname);
+ };
+
+ }
+
+ // Otherwise, implement own
+ else {
+
+ addClass = function(element, classname) {
+
+ // Simply add new class
+ element.className += " " + classname;
+
+ };
+
+ removeClass = function(element, classname) {
+
+ // Filter out classes with given name
+ element.className = element.className.replace(/([^ ]+)[ ]*/g,
+ function(match, testClassname, spaces, offset, string) {
+
+ // If same class, remove
+ if (testClassname == classname)
+ return "";
+
+ // Otherwise, allow
+ return match;
+
+ }
+ );
+
+ };
+
+ }
+
+
GuacamoleUI.hideStatus = function() {
- document.body.classList.remove("guac-error");
+ removeClass(document.body, "guac-error");
GuacamoleUI.containers.state.style.visibility = "hidden";
+ GuacamoleUI.display.style.opacity = "1";
};
GuacamoleUI.showStatus = function(text) {
- document.body.classList.remove("guac-error");
+ removeClass(document.body, "guac-error");
GuacamoleUI.containers.state.style.visibility = "visible";
GuacamoleUI.state.textContent = text;
+ GuacamoleUI.display.style.opacity = "1";
};
GuacamoleUI.showError = function(error) {
- document.body.classList.add("guac-error");
+ addClass(document.body, "guac-error");
GuacamoleUI.state.textContent = error;
+ GuacamoleUI.display.style.opacity = "0.1";
};
GuacamoleUI.shadeMenu = function() {
// Detect long-press at bottom of screen
document.body.addEventListener('touchstart', GuacamoleUI.startLongPressDetect, true);
- // Show menu if mouse leaves document
- document.addEventListener('mouseout', function(e) {
-
- // Get parent of the element the mouse pointer is leaving
- if (!e) e = window.event;
- var target = e.relatedTarget || e.toElement;
-
- // Ensure target is not document nor child of document
- var targetParent = target;
- while (targetParent != null) {
- if (targetParent == document) return;
- targetParent = targetParent.parentNode;
- }
-
- // Start detection of intent to open menu
- GuacamoleUI.startMenuOpenDetect();
-
- }, true);
-
// Reconnect button
GuacamoleUI.buttons.reconnect.onclick = function() {
window.location.reload();