2016-12-18 13:12:14 +00:00
|
|
|
<!DOCTYPE html5>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
{% import "header.html" as header %}
|
|
|
|
<title>Login/Register</title>
|
|
|
|
<meta charset="UTF-8">
|
2017-07-21 06:10:48 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
2018-02-24 20:51:36 +00:00
|
|
|
<link rel="stylesheet" href="/static/css/common.css">
|
2019-08-14 20:43:35 +00:00
|
|
|
{% if theme %}<link rel="stylesheet" href="/static/css/theme_{{theme}}.css">{% endif %}
|
2018-02-24 20:51:36 +00:00
|
|
|
<script src="/static/js/common.js"></script>
|
2018-09-23 23:50:27 +00:00
|
|
|
<script src="/static/js/api.js"></script>
|
2016-12-18 13:12:14 +00:00
|
|
|
|
|
|
|
<style>
|
2016-12-21 09:11:50 +00:00
|
|
|
input
|
|
|
|
{
|
|
|
|
width: 300px;
|
|
|
|
}
|
|
|
|
button
|
|
|
|
{
|
|
|
|
width: 80px;
|
|
|
|
}
|
|
|
|
|
2016-12-18 13:12:14 +00:00
|
|
|
#content_body
|
|
|
|
{
|
2018-10-22 01:46:27 +00:00
|
|
|
margin: auto;
|
2019-08-26 21:54:29 +00:00
|
|
|
grid-template:
|
|
|
|
"login_form register_form" auto
|
2019-09-11 08:13:10 +00:00
|
|
|
"message_area message_area" 150px
|
2019-08-26 21:54:29 +00:00
|
|
|
/ 1fr 1fr;
|
2016-12-18 13:12:14 +00:00
|
|
|
}
|
2016-12-21 09:11:50 +00:00
|
|
|
|
2019-08-26 21:54:29 +00:00
|
|
|
form
|
2016-12-18 13:12:14 +00:00
|
|
|
{
|
2019-08-26 21:54:29 +00:00
|
|
|
display: grid;
|
|
|
|
grid-auto-rows: max-content;
|
|
|
|
grid-row-gap: 8px;
|
|
|
|
margin: 0;
|
2016-12-18 13:12:14 +00:00
|
|
|
}
|
2019-08-26 21:54:29 +00:00
|
|
|
form h2
|
2016-12-18 13:12:14 +00:00
|
|
|
{
|
2019-08-26 21:54:29 +00:00
|
|
|
margin: 0;
|
2016-12-18 13:12:14 +00:00
|
|
|
}
|
2019-08-26 21:54:29 +00:00
|
|
|
#login_form { grid-area: login_form; }
|
|
|
|
#register_form { grid-area: register_form; }
|
2018-02-24 08:34:46 +00:00
|
|
|
#message_area
|
|
|
|
{
|
2019-08-26 21:54:29 +00:00
|
|
|
grid-area: message_area;
|
2018-02-24 08:34:46 +00:00
|
|
|
}
|
2019-08-26 21:54:29 +00:00
|
|
|
|
2017-07-21 06:02:09 +00:00
|
|
|
@media screen and (max-width: 800px)
|
|
|
|
{
|
2019-08-26 21:54:29 +00:00
|
|
|
#content_body
|
2017-07-21 06:02:09 +00:00
|
|
|
{
|
2019-08-26 21:54:29 +00:00
|
|
|
grid-template:
|
|
|
|
"login_form" auto
|
|
|
|
"register_form" auto
|
2019-09-11 08:13:10 +00:00
|
|
|
"message_area" 150px
|
2019-08-26 21:54:29 +00:00
|
|
|
/ 1fr;
|
2017-07-21 06:02:09 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-18 13:12:14 +00:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
|
|
<body>
|
|
|
|
{{header.make_header(session=session)}}
|
|
|
|
<div id="content_body">
|
2019-08-26 21:54:29 +00:00
|
|
|
<form id="login_form" class="panel" action="/login" method="post">
|
|
|
|
<h2>Log in</h2>
|
|
|
|
<input type="text" id="login_input_username" name="username" placeholder="username" autofocus>
|
|
|
|
<input type="password" id="login_input_password" name="password" placeholder="password">
|
|
|
|
<button type="submit" id="login_submit_button" class="green_button" onclick="login_form(event)">Log in</button>
|
|
|
|
</form>
|
|
|
|
<form id="register_form" class="panel" action="/register" method="post">
|
|
|
|
<h2>Register</h2>
|
|
|
|
<input type="text" id="register_input_username" name="username" placeholder="username (at least {{min_username_length}})">
|
|
|
|
<input type="text" id="register_input_display_name" name="display_name" placeholder="display name (optional)">
|
|
|
|
<input type="password" id="register_input_password_1" name="password_1" placeholder="password (at least {{min_password_length}})">
|
|
|
|
<input type="password" id="register_input_password_2" name="password_2" placeholder="password again">
|
|
|
|
<button type="submit" id="register_input_button" class="green_button" onclick="register_form(event)">Register</button>
|
|
|
|
</form>
|
2016-12-21 09:11:50 +00:00
|
|
|
<div id="message_area">
|
2016-12-18 13:12:14 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2016-12-21 09:11:50 +00:00
|
|
|
var message_area = document.getElementById("message_area");
|
|
|
|
|
2019-08-26 21:34:50 +00:00
|
|
|
function login_form(event)
|
2016-12-21 09:11:50 +00:00
|
|
|
{
|
2019-08-26 21:34:50 +00:00
|
|
|
event.preventDefault();
|
2016-12-21 09:11:50 +00:00
|
|
|
var username = document.getElementById("login_input_username").value;
|
|
|
|
var password = document.getElementById("login_input_password").value;
|
|
|
|
if (username == "" || password == "")
|
|
|
|
{
|
2018-07-29 08:25:53 +00:00
|
|
|
common.create_message_bubble(message_area, "message_negative", "Fill out the form, yo.");
|
2016-12-21 09:11:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-09-23 23:50:27 +00:00
|
|
|
api.users.login(username, password, receive_callback)
|
2018-07-29 08:25:53 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 21:34:50 +00:00
|
|
|
function register_form(event)
|
2016-12-21 09:11:50 +00:00
|
|
|
{
|
2019-08-26 21:34:50 +00:00
|
|
|
event.preventDefault();
|
2016-12-21 09:11:50 +00:00
|
|
|
var username = document.getElementById("register_input_username").value;
|
2019-08-26 21:32:51 +00:00
|
|
|
var display_name = document.getElementById("register_input_display_name").value;
|
2016-12-21 09:11:50 +00:00
|
|
|
var password_1 = document.getElementById("register_input_password_1").value;
|
|
|
|
var password_2 = document.getElementById("register_input_password_2").value;
|
|
|
|
if (username == "" || password_1 == "" || password_2 == "")
|
|
|
|
{
|
2018-07-29 08:25:53 +00:00
|
|
|
common.create_message_bubble(message_area, "message_negative", "Fill out the form, yo.");
|
2016-12-21 09:11:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-26 21:32:51 +00:00
|
|
|
api.users.register(username, display_name, password_1, password_2, receive_callback);
|
2016-12-21 09:11:50 +00:00
|
|
|
}
|
2018-07-29 08:25:53 +00:00
|
|
|
|
2016-12-21 09:11:50 +00:00
|
|
|
function receive_callback(response)
|
|
|
|
{
|
2018-02-18 02:47:17 +00:00
|
|
|
response = response["data"];
|
2017-03-08 05:15:15 +00:00
|
|
|
if ("error_type" in response)
|
2016-12-21 09:11:50 +00:00
|
|
|
{
|
2018-07-29 08:25:53 +00:00
|
|
|
common.create_message_bubble(message_area, "message_negative", response["error_message"]);
|
|
|
|
return;
|
2016-12-21 09:11:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window.location.href = "/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-18 13:12:14 +00:00
|
|
|
</script>
|
|
|
|
</html>
|