initial frontend commit
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
@@ -0,0 +1,5 @@
|
||||
#shorten-form {
|
||||
width: 300px;
|
||||
margin: auto;
|
||||
margin-top: 10vh;
|
||||
}
|
Reference in New Issue
Block a user