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;
}