frontend: removed unneeded dependencies

This commit is contained in:
2017-08-31 12:43:38 +02:00
parent 27461dd3f5
commit e7f3cfc2b9
3 changed files with 12 additions and 13 deletions

View File

@@ -1 +1 @@
[]
[{"url":"http://blog.veitheller.de/","shortened":"http://ve.it/ZJ8Frxx"}]

View File

@@ -1,18 +1,19 @@
var form = document.getElementById('shorten-form');
var urlBox = form.elements[0];
var box = form.elements[0];
var link = document.getElementById('link');
var shrBox = document.getElementById('shortened');
var shrt = document.getElementById('shortened');
function displayShortenedUrl(response) {
link.textContent = response.data.url;
link.setAttribute(
'href', response.data.url
);
shrBox.style.opacity = '1';
urlBox.value = '';
function d(data) {
link.textContent = data.url;
link.setAttribute('href', data.url);
shrt.style.opacity = '1';
box.value = '';
}
form.addEventListener('submit', function(e) {
e.preventDefault();
axios.post('/new', { url: urlBox.value }).then(displayShortenedUrl);
fetch('/new', { method: 'POST', body: JSON.stringify({ url: box.value })})
.then(x => x.json())
.then(d);
});

View File

@@ -57,8 +57,6 @@
</div>
</div>
<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/script.js"></script>
</body>
</html>