1 <?xml version="1.0" encoding="UTF-8"?>
5 Guacamole - Clientless Remote Desktop
6 Copyright (C) 2010 Michael Jumper
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 <html xmlns="http://www.w3.org/1999/xhtml">
25 <link rel="icon" type="image/png" href="images/guacamole-logo-64.png"/>
26 <link rel="stylesheet" type="text/css" href="styles/login.css"/>
27 <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"/>
28 <title>Guacamole ${project.version}</title>
33 <div id="login-ui" style="display: none">
34 <div id="login-dialog-middle">
36 <div id="login-dialog">
38 <p id="login-error"></p>
40 <form id="login-form" action="#" method="post">
42 <div id="login-fields">
46 <td><input type="text" name="username" id="username" autofocus="autofocus"/></td>
50 <td><input type="password" name="password" id="password"/></td>
54 <img class="logo" src="images/guacamole-logo-64.png" alt=""/>
58 <input type="submit" name="login" id="login" value="Login"/>
67 <!-- Connection list UI -->
68 <div id="connection-list-ui" style="display: none">
70 <div id="logout-panel">
71 <button id="logout">Logout</button>
75 <img class="logo" src="images/guacamole-logo-64.png" alt=""/>
79 <table class="connections">
82 <th class="protocol"> </th>
83 <th class="name">Name</th>
86 <tbody id="connections-tbody">
92 <div id="version-dialog">
93 Guacamole ${project.version}
96 <script type="text/javascript" src="scripts/connections.js"></script>
99 <script type="text/javascript"> /* <![CDATA[ */
101 // Constructs the URL for a client which connects to the connection
102 // with the given id.
103 function getClientURL(id) {
105 // Construct URL for client with given id
106 return "client.xhtml?id=" + encodeURIComponent(id);
110 // Resets the interface such that the login UI is displayed if
111 // the user is not authenticated (or authentication fails) and
112 // the connection list UI (or the client for the only available
113 // connection, if there is only one) is displayed if the user is
117 // Get parameters from query string
118 var parameters = window.location.search.substring(1);
122 configs = getConfigList(parameters);
126 // Show login UI if unable to get configs
127 loginUI.style.display = "";
128 connectionListUI.style.display = "none";
134 // If only one connection, redirect to that.
135 if (configs.length == 1) {
136 window.location.href = getClientURL(configs[0].id);
140 // Remove all rows from connections list
141 var tbody = document.getElementById("connections-tbody");
142 tbody.innerHTML = "";
144 // Add one row per connection
145 for (var i=0; i<configs.length; i++) {
147 // Create row and cells
148 var tr = document.createElement("tr");
149 var protocol = document.createElement("td");
150 var id = document.createElement("td");
152 var protocolIcon = document.createElement("div");
153 protocolIcon.className = "protocol icon " + configs[i].protocol;
156 protocol.className = "protocol";
157 id.className = "name";
159 // Create link to client
160 var clientLink = document.createElement("a");
161 clientLink.setAttribute("href", getClientURL(configs[i].id));
164 protocol.appendChild(protocolIcon);
165 //protocol.textContent = configs[i].protocol;
166 clientLink.textContent = configs[i].id;
167 id.appendChild(clientLink);
170 tr.appendChild(protocol);
174 tbody.appendChild(tr);
178 // If configs could be retrieved, display list
179 loginUI.style.display = "none";
180 connectionListUI.style.display = "";
184 var loginForm = document.getElementById("login-form");
185 var loginUI = document.getElementById("login-ui");
186 var connectionListUI = document.getElementById("connection-list-ui");
187 var logout = document.getElementById("logout");
189 logout.onclick = function() {
190 window.location.href = "logout";
193 loginForm.onsubmit = function() {
195 // Get parameters from query string
196 var parameters = window.location.search.substring(1);
198 // Get username and password from form
199 var username = document.getElementById("username");
200 var password = document.getElementById("password");
203 "username=" + encodeURIComponent(username.value)
204 + "&password=" + encodeURIComponent(password.value)
206 // Include query parameters in submission data
207 if (parameters) data += "&" + parameters;
212 var xhr = new XMLHttpRequest();
213 xhr.open("POST", "login", false);
214 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
218 if (xhr.status != 200)
219 throw new Error("Invalid login");
226 var loginError = document.getElementById("login-error");
228 // Display error, reset and refocus password field
229 loginError.textContent = e.message;
237 // On success, hide loginUI, get and show connection list.