2022-10-12 19:55:22 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset='utf-8'>
|
|
|
|
<title>Schafkopf</title>
|
|
|
|
<meta name='viewport' content='width=device-width, initial-scale=1'/>
|
|
|
|
<link rel='stylesheet' type='text/css' media='screen' href='style.css'/>
|
|
|
|
<link rel='stylesheet' type='text/css' media='screen' href='login.css'/>
|
|
|
|
<script src='api.js'></script>
|
|
|
|
<script src='storage.js'></script>
|
|
|
|
<script src='login.js'></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="login-window">
|
|
|
|
<div id="login-window-vertical-center">
|
|
|
|
<div id="login-window-inner">
|
|
|
|
<div id="sheephead-logo">\_______/<br>\ - - /<br>\ | /<br>\_/<br><br>Sheephead</div>
|
|
|
|
<label for="usrname">Username<a href="register.html">Create account</a></label>
|
|
|
|
<input type="text" id="user-name" name="usrname" required/>
|
|
|
|
|
|
|
|
<label for="psw">Password<a href="reset.html">Reset password</a></label>
|
|
|
|
<input type="password" id="user-pwd" name="psw" required/>
|
|
|
|
|
|
|
|
<button class="login-buttons standard-button" onclick="loginUser()">Log in</button>
|
|
|
|
<div id="user-hint"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
function loginUser() {
|
|
|
|
const username = getLoginName();
|
|
|
|
const password = getLoginPassword();
|
|
|
|
if (username == "") {
|
|
|
|
setTextHint("Please enter your user name");
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (password == "") {
|
|
|
|
setTextHint("Please enter a password");
|
|
|
|
return
|
|
|
|
}
|
|
|
|
performLoginPlayerRequest(username, password)
|
2022-10-13 09:13:36 +02:00
|
|
|
.catch(function(error) {
|
2022-10-12 19:55:22 +02:00
|
|
|
console.log("Failed to log in")
|
|
|
|
console.log(error)
|
|
|
|
// TODO: Create better error message for user
|
|
|
|
setTextHint(error);
|
|
|
|
})
|
2022-10-13 09:13:36 +02:00
|
|
|
.then(function(token) {
|
|
|
|
storePlayerNameAndToken(username, token);
|
|
|
|
showTableList();
|
|
|
|
})
|
2022-10-12 19:55:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function showDebugLogins() {
|
|
|
|
document.getElementById("login-window-inner").innerHTML +=
|
|
|
|
"<button class=\"login-buttons standard-button\" onclick=\"loginDebugUser('a')\">Player A</button>" +
|
|
|
|
"<button class=\"login-buttons standard-button\" onclick=\"loginDebugUser('b')\">Player B</button>" +
|
|
|
|
"<button class=\"login-buttons standard-button\" onclick=\"loginDebugUser('c')\">Player C</button>" +
|
|
|
|
"<button class=\"login-buttons standard-button\" onclick=\"loginDebugUser('d')\">Player D</button>"
|
|
|
|
}
|
|
|
|
|
|
|
|
function loginDebugUser(name) {
|
|
|
|
setLoginName(name)
|
|
|
|
setLoginPassword(name)
|
|
|
|
loginUser()
|
|
|
|
}
|
|
|
|
|
|
|
|
loadExistingSession()
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|