initial frontend commit

This commit is contained in:
2017-08-27 15:33:59 +02:00
parent 43393cfe9c
commit 6f98b217ac
3 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
var form = document.getElementById('shorten-form');
var urlBox = form.elements[0];
var link = document.getElementById('link');
var shrBox = document.getElementById('shortened');
function displayShortenedUrl(response) {
link.textContent = response.data.shortUrl;
link.setAttribute(
'href', response.data.shortUrl
);
shrBox.style.opacity = '1';
urlBox.value = '';
}
form.addEventListener('submit', function(e) {
e.preventDefault();
axios.post('/new', { url: urlBox.value }).then(displayShortenedUrl);
});

View File

@@ -0,0 +1,5 @@
#shorten-form {
width: 300px;
margin: auto;
margin-top: 10vh;
}

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<title>shrt</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="public/style.css">
</head>
<body>
<header>
<main>
<div class="container">
<form id="shorten-form" method="POST">
<input id="url" type="text" placeholder="URL" name="url">
<input id="submit" type="submit" value="Shorten!">
</form>
<div class="row">
<div class="column">
<section id="shortened">
<p>
<em>Your shortened link: </em>
<a id="link" href="#" target="_blank">Loading...</a>
</p>
<p>
Right-click or Tap &amp; Hold the link and copy the address to clipboard and start using it.
</p>
</section>
</div>
</div>
</div>
</main>
<script src="https://cdn.jsdelivr.net/bluebird/latest/bluebird.min.js"></script>
<script src="https://npmcdn.com/axios/dist/axios.min.js"></script>
<script src="public/scripts.js"></script>
</body>
</html>