Added the url page and changed the title to an anchor tag

This commit is contained in:
xemeds
2020-07-20 14:09:03 +00:00
parent 0db137daf5
commit 2de586b87b
5 changed files with 81 additions and 50 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ def index():
# If the form was valid
if form.validate_on_submit():
return "Valid URL: " + form.url.data
return render_template("url.html", url=form.url.data)
# If the form was invalid or not submitted
else:
+11 -5
View File
@@ -9,7 +9,7 @@ body {
}
.header {
.headers {
position: absolute;
margin-left: auto;
margin-right: auto;
@@ -19,9 +19,15 @@ body {
text-align: center;
}
.title {
color: #ffffff;
.title:link {
color: #bb86fc;
text-decoration: none;
font-size: 50px;
font-weight: bold;
}
.title:hover {
color: #7b59a5;
}
.desc {
@@ -61,7 +67,7 @@ body {
border-color: #7b59a5;
}
.submit {
.button {
background: #bb86fc;
border: 2px solid #bb86fc;
border-radius: 3px;
@@ -71,7 +77,7 @@ body {
margin: 0 3% 0 1%;
}
.submit:hover {
.button:hover {
background: #7b59a5;
border-color: #7b59a5;
}
+42 -41
View File
@@ -3,58 +3,59 @@
{% block body %}
{% if form.url.errors %}
<body>
<div class="header">
<h1 class="title">tiny0</h1>
<div class="headers">
<a class="title" href="{{ url_for('index') }}">tiny0</a>
<h1 class="desc">Custom URL Shortener</h1>
</div>
{% else %}
<body onload="typeTitle()">
<div class="header">
<h1 id="title" class="title"></h1>
<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", class="url") }}
{{ form.submit(class="button") }}
</div>
</form>
{% if form.url.errors %}
{% for error in form.url.errors %}
<p class="error-message">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
<div class="container">
<form method="POST" action="">
{{ form.hidden_tag() }}
<div class="inputs">
{{ form.url(placeholder="Enter the URL here", class="url") }}
{{ form.submit(class="submit") }}
</div>
</form>
{% if form.url.errors %}
{% for error in form.url.errors %}
<p class="error-message">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
{% if not form.url.errors %}
<script>
var i = 0;
var title_text = "tiny0";
var desc_text = "Custom URL Shortener";
var speed = 120;
<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);
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)
}
}
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);
function typeDesc() {
if (i < desc_text.length) {
document.getElementById("desc").innerHTML += desc_text.charAt(i);
i++;
setTimeout(typeDesc, speed);
}
}
}
</script>
</script>
{% endif %}
</body>
{% endblock %}
+1 -3
View File
@@ -11,9 +11,7 @@
<div id="page-container">
<div id="content-wrap">
{% block body %}{% endblock %}
{% block body %}{% endblock %}
</div>
</div>
+26
View File
@@ -0,0 +1,26 @@
{% extends "layout.html" %}
{% block body %}
<body>
<div class="headers">
<a class="title" href="{{ url_for('index') }}">tiny0</a>
<h1 class="desc">Custom URL Shortener</h1>
</div>
<div class="container">
<div class="inputs">
<input type="text" value="{{ url }}" id="url" class="url" readonly>
<button onclick="copyURL()" class="button">Copy</button>
</div>
</div>
<script>
function copyURL() {
var url = document.getElementById("url");
url.select();
url.setSelectionRange(0, 99999)
document.execCommand("copy");
}
</script>
</body>
{% endblock %}