{% extends 'w3bsite/classes/apps/defaults/html/base.html' %}
{% load static %}
{% block content %}

<!-- JS -->
<script type="text/javascript">
	toggle_topbar("hide")
	toggle_leftbar("hide")
	toggle_rightbar("hide")
</script>

<!-- CONTENT -->
<div class="full_window_centered">
	<img src="{% static 'favicon.png' %}" width="45px" height="45px" style="display: block; margin: 0 auto; margin-bottom: 35px;">

	<!-- SIGN UP -->
	<div class="widget_container">
		<div class="widget_child">
			<h1 class="title">
				Sign Up
			</h1>		
			<p class="text" style="">
				Enter your information to sign up.
			</p>
			<input id="username" type="username" placeholder="Username" class="input" style="margin-bottom: 5px;">
			<input id="email" type="email" placeholder="Your Email" class="input" style="margin-bottom: 5px;">
			<input id="password" type="password" autocomplete="off" placeholder="Your Passphrase" class="input" style="margin-bottom: 5px;">
			<input id="verify_password" type="password" autocomplete="off" placeholder="Verify Passphrase" class="input" style="margin-bottom: 5px;">
			<p class="text" id="response" style="display: none; font-size: 12px; overflow: scroll;"></p>
			<div class="loader" id="loader" style="transform: scale(0.33); display: block; margin: 0 auto; display: none;"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
			<div style="display: flex;">
				<button class="button" style="width: 49%;">
					<a href="/authentication/signin/" class="empty_a">
						Sign In
					</a>
				</button>
				<div style="width: 2%; height: 1%;"></div>
				<button class="button" style="width: 49%;" onclick="__signup__()">
					<a href="#" class="empty_a">
						Sign Up
					</a>
				</button>
			</div>
		</div>
	</div>

	<h1 class="text_reversed" style="font-size: 6px; font-weight: 400; margin-top: 35px;">
		© 2020 VanDenBerghInc. All Rights Reserved.
	</h1>
</div>

<!-- JAVASCRIPT -->
<script type="text/javascript">
	
	// sign up request.
	function __signup__() {
		var response_element = document.getElementById("response")
		var username = document.getElementById("username").value
		var email = document.getElementById("email").value
		var password = document.getElementById("password").value;
		request("/requests/authentication/signup/", {
			username:username,
			email:email,
			password:password,
			verify_password:document.getElementById("verify_password").value,
			response:response_element,
			loader:document.getElementById("loader"),
		}, function(response) {
			if (response.error == null) {
				setTimeout(function() {
					sign_in(email, password, function(response) {
						if (response.error == null) {
							location.href = "/authentication/activate/"
						} else {
							location.href = "/authentication/signin/"
						}
					}, function(response) {
						if (response.error == null) {
							location.href = "/authentication/activate/"
						} else {
							location.href = "/authentication/signin/"
						}
					})
				}, 1500)
			}
		})
	}

</script>

{% endblock %}