Add text field event target, focus event target if "Show Keyboard" is clicked and...
[guacamole.git] / src / main / webapp / client.xhtml
index 71d519d..3523bae 100644 (file)
 
         </div>
 
+        <input id="eventTarget"
+               type="text"
+               style="width: 0; height: 0; position: fixed; opacity: 0"
+               value="x"/>
 
         <!-- Display -->
-        <div id="display" class="guac-display guac-loading">
+        <div id="display">
             
             <!-- Menu trigger -->
             <div id="menuControl"></div>
 
             // Start connect after control returns from onload (allow browser
             // to consider the page loaded).
-            document.body.onload = function() {
-
+            window.onload = function() {
                 window.setTimeout(function() {
+
+                    var tunnel;
+
+                    // If WebSocket available, try to use it.
+                    if (window.WebSocket)
+                        tunnel = new Guacamole.ChainedTunnel(
+                            new Guacamole.WebSocketTunnel("websocket-tunnel"),
+                            new Guacamole.HTTPTunnel("tunnel")
+                        );
+
+                    // If no WebSocket, then use HTTP.
+                    else
+                        tunnel = new Guacamole.HTTPTunnel("tunnel")
+
                     // Instantiate client
-                    var guac = new Guacamole.Client(
-                        GuacamoleUI.display,
-                        new Guacamole.HTTPTunnel("tunnel")
-                    );
+                    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);
                     catch (e) {
                         GuacamoleUI.showError(e.message);
                     }
-                }, 0);
 
+                }, 0);
             };
 
         /* ]]> */ </script>