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 // Get parameters from query string
106 var parameters = window.location.search.substring(1);
108 // Construct URL for client, including any additional
109 // parameters from the query string
110 var client_url = "client.xhtml?id=" + encodeURIComponent(id);
111 if (parameters) client_url += "&" + parameters;
117 // Resets the interface such that the login UI is displayed if
118 // the user is not authenticated (or authentication fails) and
119 // the connection list UI (or the client for the only available
120 // connection, if there is only one) is displayed if the user is
126 configs = getConfigList();
130 // Show login UI if unable to get configs
131 loginUI.style.display = "";
132 connectionListUI.style.display = "none";
138 // If only one connection, redirect to that.
139 if (configs.length == 1) {
140 window.location.href = getClientURL(configs[0].id);
144 // Remove all rows from connections list
145 var tbody = document.getElementById("connections-tbody");
146 tbody.innerHTML = "";
148 // Add one row per connection
149 for (var i=0; i<configs.length; i++) {
151 // Create row and cells
152 var tr = document.createElement("tr");
153 var protocol = document.createElement("td");
154 var id = document.createElement("td");
156 var protocolIcon = document.createElement("div");
157 protocolIcon.className = "protocol icon " + configs[i].protocol;
160 protocol.className = "protocol";
161 id.className = "name";
163 // Create link to client
164 var clientLink = document.createElement("a");
165 clientLink.setAttribute("href", getClientURL(configs[i].id));
168 protocol.appendChild(protocolIcon);
169 //protocol.textContent = configs[i].protocol;
170 clientLink.textContent = configs[i].id;
171 id.appendChild(clientLink);
174 tr.appendChild(protocol);
178 tbody.appendChild(tr);
182 // If configs could be retrieved, display list
183 loginUI.style.display = "none";
184 connectionListUI.style.display = "";
188 var loginForm = document.getElementById("login-form");
189 var loginUI = document.getElementById("login-ui");
190 var connectionListUI = document.getElementById("connection-list-ui");
191 var logout = document.getElementById("logout");
193 logout.onclick = function() {
194 window.location.href = "logout";
197 loginForm.onsubmit = function() {
199 var username = document.getElementById("username");
200 var password = document.getElementById("password");
203 "username=" + encodeURIComponent(username.value)
204 + "&password=" + encodeURIComponent(password.value)
209 var xhr = new XMLHttpRequest();
210 xhr.open("POST", "login", false);
211 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
215 if (xhr.status != 200)
216 throw new Error("Invalid login");
223 var loginError = document.getElementById("login-error");
225 // Display error, reset and refocus password field
226 loginError.textContent = e.message;
234 // On success, hide loginUI, get and show connection list.