Add tunnel, httpendpoint and wsendpoint parameters to client.xhtml
[guacamole.git] / src / main / webapp / client.xhtml
index 7c38668..afec1b4 100644 (file)
 
         </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>
 
@@ -84,9 +96,6 @@
             </div>
         </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>
-
         <!-- guacamole-common-js scripts -->
         <script type="text/javascript" src="guacamole-common-js/keyboard.js"></script>
         <script type="text/javascript" src="guacamole-common-js/mouse.js"></script>
 
                     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")
-                        );
+                    function getParameter (paramName, defaultValue) {
+                       var regex = new RegExp('[?][^#]*' + paramName + '=([^&#]*)');
+                       if (typeof defaultValue === 'undefined') {
+                           defaultValue = null;
+                       }
+                       return (window.location.href.match(regex) || ['', defaultValue])[1];
+                    }
 
-                    // If no WebSocket, then use HTTP.
-                    else
-                        tunnel = new Guacamole.HTTPTunnel("tunnel")
+                    var tunneltype = getParameter("tunnel");
+                    var wsendpoint = getParameter("wsendpoint", "websocket-tunnel");
+                    var httpendpoint = getParameter("httpendpoint", "tunnel");
+
+                    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);