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 <title>Guacamole ${project.version}</title>
32 <div id="login-ui" style="display: none">
33 <div id="login-dialog-middle">
35 <div id="login-dialog">
37 <p id="login-error"></p>
39 <form id="login-form" action="#" method="post">
41 <div id="login-fields">
45 <td><input type="text" name="username" id="username" autofocus="autofocus"/></td>
49 <td><input type="password" name="password" id="password"/></td>
53 <img class="logo" src="images/guacamole-logo-64.png" alt=""/>
57 <input type="submit" name="login" id="login" value="Login"/>
66 <!-- Connection list UI -->
67 <div id="connection-list-ui" style="display: none">
70 <img class="logo" src="images/guacamole-logo-64.png" alt=""/>
74 <table class="connections">
77 <th class="protocol">Protocol</th>
78 <th class="name">Name</th>
81 <tbody id="connections-tbody">
87 <div id="version-dialog">
88 Guacamole ${project.version}
92 <script type="text/javascript"> /* <![CDATA[ */
94 function Config(protocol, id) {
95 this.protocol = protocol;
99 function getConfigList() {
102 var xhr = new XMLHttpRequest();
103 xhr.open("GET", "configs", false);
106 // If fail, throw error
107 if (xhr.status != 200)
108 throw new Error(xhr.statusText);
110 // Otherwise, get list
111 var configs = new Array();
113 var configElements = xhr.responseXML.getElementsByTagName("config");
114 for (var i=0; i<configElements.length; i++) {
115 configs.push(new Config(
116 configElements[i].getAttribute("protocol"),
117 configElements[i].getAttribute("id")
129 configs = getConfigList();
135 // Show login UI if unable to get configs
136 loginUI.style.display = "";
137 connectionListUI.style.display = "none";
143 // Remove all rows from connections list
144 var tbody = document.getElementById("connections-tbody");
145 tbody.innerHTML = "";
147 // Add one row per connection
148 for (var i=0; i<configs.length; i++) {
150 // Create row and cells
151 var tr = document.createElement("tr");
152 var protocol = document.createElement("td");
153 var id = document.createElement("td");
156 protocol.className = "protocol";
157 id.className = "name";
159 // Create link to client
160 var clientLink = document.createElement("a");
161 clientLink.setAttribute("href",
162 "client.xhtml?" + encodeURIComponent(configs[i].id));
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");
188 // TODO: Get connection list
189 // On no-auth fail, show login UI
191 loginForm.onsubmit = function() {
193 var username = document.getElementById("username");
194 var password = document.getElementById("password");
197 "username=" + encodeURIComponent(username.value)
198 + "&password=" + encodeURIComponent(password.value)
203 var xhr = new XMLHttpRequest();
204 xhr.open("POST", "login", false);
205 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
209 if (xhr.status != 200)
210 throw new Error("Invalid login");
217 var loginError = document.getElementById("login-error");
219 // Display error, reset and refocus password field
220 loginError.textContent = e.message;
228 // On success, hide loginUI, get and show connection list.