Cleaned up the templates

This commit is contained in:
xemeds
2020-08-19 16:31:22 +03:00
parent 789afe8554
commit 59cbba9d03
7 changed files with 93 additions and 104 deletions
+13 -57
View File
@@ -1,62 +1,18 @@
{% extends "layout.html" %}
{% block body %}
{% if form.url.errors %}
<body>
<div class="headers">
<a class="title" href="{{ url_for('index') }}">tiny0</a>
<h1 class="desc">Custom URL Shortener</h1>
<div class="container">
<form method="POST" action="">
{{ form.hidden_tag() }}
<div class="inputs">
{{ form.url(placeholder="Enter the URL here", autofocus=true, class="url") }}
{{ form.submit(class="button") }}
</div>
{% else %}
<body onload="typeTitle()">
<div class="headers">
<a class="title" id="title" href="{{ url_for('index') }}"></a>
<h1 id="desc" class="desc"></h1>
</div>
{% endif %}
<div class="container">
<form method="POST" action="">
{{ form.hidden_tag() }}
<div class="inputs">
{{ form.url(placeholder="Enter the URL here", autofocus=true, class="url") }}
{{ form.submit(class="button") }}
</div>
{% if form.url.errors %}
{% for error in form.url.errors %}
<p class="url-error-message">{{ error }}</p>
{% endfor %}
{% endif %}
</form>
</div>
{% if not form.url.errors %}
<script>
var i = 0;
var title_text = "tiny0";
var desc_text = "Custom URL Shortener";
var speed = 120;
function typeTitle() {
if (i < title_text.length) {
document.getElementById("title").innerHTML += title_text.charAt(i);
i++;
setTimeout(typeTitle, speed);
}
else {
i = 0;
setTimeout(typeDesc, 200)
}
}
function typeDesc() {
if (i < desc_text.length) {
document.getElementById("desc").innerHTML += desc_text.charAt(i);
i++;
setTimeout(typeDesc, speed);
}
}
</script>
{% endif %}
</body>
{% if form.url.errors %}
{% for error in form.url.errors %}
<p class="url-error-message">{{ error }}</p>
{% endfor %}
{% endif %}
</form>
</div>
{% endblock %}