Allow logout button to work where no Java app used
[guacamole.git] / src / main / webapp / client.xhtml
index 21a837f..66d6184 100644 (file)
@@ -26,6 +26,7 @@
         <link rel="stylesheet" type="text/css" href="styles/client.css"/>
         <link rel="stylesheet" type="text/css" href="styles/keyboard.css"/>
         <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi"/>
+        <meta name="apple-mobile-web-app-capable" content="yes"/>
         <title>Guacamole ${project.version}</title>
     </head>
 
 
         </div>
 
+        <!-- Touch-specific menu -->
+        <div id="touchMenu"><img id="touchShowClipboard" src="images/menu-icons/tango/edit-paste.png"/><img id="touchShowKeyboard" src="images/menu-icons/tango/input-keyboard.png"/><img id="touchLogout" src="images/menu-icons/tango/system-log-out.png"/></div>
+
+        <!-- Touch-specific clipboard -->
+        <div id="touchClipboardDiv">
+            <h2>Clipboard</h2>
+            <p>
+            Text copied/cut within Guacamole will appear here. Changes to the text will affect the remote clipboard, and will be pastable within the remote desktop. Use the textbox below as an interface between the client and server clipboards.
+            </p>
+            <textarea rows="10" cols="40" id="touchClipboard"></textarea>
+        </div>
+
+        <!-- Keyboard event target for platforms with native OSKs -->
+        <textarea id="eventTarget"></textarea>
 
         <!-- Display -->
-        <div id="display" class="guac-display guac-loading">
+        <div id="display">
             
             <!-- Menu trigger -->
             <div id="menuControl"></div>
         <!-- Init -->
         <script type="text/javascript"> /* <![CDATA[ */
 
-            // Instantiate client
-            var guac = new Guacamole.Client(
-                GuacamoleUI.display,
-                new Guacamole.HTTPTunnel("tunnel")
-            );
-
-            // Tie UI to client
-            GuacamoleUI.attach(guac);
-
-            try {
-
-                // Get ID
-                var id = window.location.search.substring(1);
-
-                // Connect client
-                guac.connect("id=" + id);
-
-            }
-            catch (e) {
-                GuacamoleUI.showError(e.message);
-            }
-
-            /* ]]> */ </script>
+            // Start connect after control returns from onload (allow browser
+            // to consider the page loaded).
+            window.onload = function() {
+                window.setTimeout(function() {
+
+                    var tunnel;
+
+                    function getParameter (paramName, defaultValue) {
+                       var regex = new RegExp('[?][^#]*' + paramName + '=([^&#]*)');
+                       if (typeof defaultValue === 'undefined') {
+                           defaultValue = null;
+                       }
+                       return (window.location.href.match(regex) || ['', defaultValue])[1];
+                    }
+
+                    var tunneltype = getParameter("tunnel");
+                    var wsendpoint = getParameter("wsendpoint", "websocket-tunnel");
+                    var httpendpoint = getParameter("httpendpoint", "tunnel");
+                     /* Should Window close on logout */
+                    window.SELF_CLOSE = getParameter("selfclose", 0); /* if 1 then the window will close on logout if 0 then the logout will redirect, defaults to 0 */
+
+                    switch (tunneltype) {
+                      case 'http':
+                        tunnel = new Guacamole.HTTPTunnel(httpendpoint);
+                        break;
+                      case 'ws':
+                        if (window.WebSocket)
+                            tunnel = new Guacamole.WebSocketTunnel(wsendpoint);
+                        break;
+                      case 'chained':
+                        if (window.WebSocket)
+                            tunnel = new Guacamole.ChainedTunnel(
+                                new Guacamole.WebSocketTunnel(wsendpoint),
+                                new Guacamole.HTTPTunnel(httpendpoint)
+                            );
+                        break;
+                      default:
+                        // Try to guess what tunnel we are using
+                        // If WebSocket available, try to use it.
+                        if (window.WebSocket)
+                            tunnel = new Guacamole.ChainedTunnel(
+                                new Guacamole.WebSocketTunnel(wsendpoint),
+                                new Guacamole.HTTPTunnel(httpendpoint)
+                            );
+                        // If no WebSocket, then use HTTP.
+                        else
+                            tunnel = new Guacamole.HTTPTunnel(httpendpoint);
+                        break;
+                    }
+
+                    // Instantiate client
+                    var guac = new Guacamole.Client(tunnel);
+
+                    // Add client to UI
+                    guac.getDisplay().className = "software-cursor";
+                    GuacamoleUI.display.appendChild(guac.getDisplay());
+
+                    // Tie UI to client
+                    GuacamoleUI.attach(guac);
+
+                    try {
+
+                        // Get entire query string, and pass to connect().
+                        // Normally, only the "id" parameter is required, but
+                        // all parameters should be preserved and passed on for
+                        // the sake of authentication.
+
+                        var connect_string = window.location.search.substring(1);
+                        guac.connect(connect_string);
+
+                    }
+                    catch (e) {
+                        GuacamoleUI.showError(e.message);
+                    }
+
+                }, 0);
+            };
+
+        /* ]]> */ </script>
 
     </body>