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 <a href="logout">Logout</a>
74 <img class="logo" src="images/guacamole-logo-64.png" alt=""/>
78 <table class="connections">
81 <th class="protocol">Protocol</th>
82 <th class="name">Name</th>
85 <tbody id="connections-tbody">
91 <div id="version-dialog">
92 Guacamole ${project.version}
96 <script type="text/javascript"> /* <![CDATA[ */
98 function Config(protocol, id) {
99 this.protocol = protocol;
103 function getConfigList() {
106 var xhr = new XMLHttpRequest();
107 xhr.open("GET", "configs", false);
110 // If fail, throw error
111 if (xhr.status != 200)
112 throw new Error(xhr.statusText);
114 // Otherwise, get list
115 var configs = new Array();
117 var configElements = xhr.responseXML.getElementsByTagName("config");
118 for (var i=0; i<configElements.length; i++) {
119 configs.push(new Config(
120 configElements[i].getAttribute("protocol"),
121 configElements[i].getAttribute("id")
133 configs = getConfigList();
137 // Show login UI if unable to get configs
138 loginUI.style.display = "";
139 connectionListUI.style.display = "none";
145 // If only one connection, redirect to that.
146 if (configs.length == 1) {
147 window.location.href = "client.xhtml?" + encodeURIComponent(configs[0].id);
151 // Remove all rows from connections list
152 var tbody = document.getElementById("connections-tbody");
153 tbody.innerHTML = "";
155 // Add one row per connection
156 for (var i=0; i<configs.length; i++) {
158 // Create row and cells
159 var tr = document.createElement("tr");
160 var protocol = document.createElement("td");
161 var id = document.createElement("td");
164 protocol.className = "protocol";
165 id.className = "name";
167 // Create link to client
168 var clientLink = document.createElement("a");
169 clientLink.setAttribute("href",
170 "client.xhtml?" + encodeURIComponent(configs[i].id));
173 protocol.textContent = configs[i].protocol;
174 clientLink.textContent = configs[i].id;
175 id.appendChild(clientLink);
178 tr.appendChild(protocol);
182 tbody.appendChild(tr);
186 // If configs could be retrieved, display list
187 loginUI.style.display = "none";
188 connectionListUI.style.display = "";
192 var loginForm = document.getElementById("login-form");
193 var loginUI = document.getElementById("login-ui");
194 var connectionListUI = document.getElementById("connection-list-ui");
196 // TODO: Get connection list
197 // On no-auth fail, show login UI
199 loginForm.onsubmit = function() {
201 var username = document.getElementById("username");
202 var password = document.getElementById("password");
205 "username=" + encodeURIComponent(username.value)
206 + "&password=" + encodeURIComponent(password.value)
211 var xhr = new XMLHttpRequest();
212 xhr.open("POST", "login", false);
213 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
217 if (xhr.status != 200)
218 throw new Error("Invalid login");
225 var loginError = document.getElementById("login-error");
227 // Display error, reset and refocus password field
228 loginError.textContent = e.message;
236 // On success, hide loginUI, get and show connection list.