From e7f3cfc2b949c6959ebed25a2764ccfb29d97005 Mon Sep 17 00:00:00 2001 From: hellerve Date: Thu, 31 Aug 2017 12:43:38 +0200 Subject: [PATCH] frontend: removed unneeded dependencies --- model.json | 2 +- public/script.js | 21 +++++++++++---------- views/index.html | 2 -- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/model.json b/model.json index fe51488..157bbf3 100644 --- a/model.json +++ b/model.json @@ -1 +1 @@ -[] +[{"url":"http://blog.veitheller.de/","shortened":"http://ve.it/ZJ8Frxx"}] \ No newline at end of file diff --git a/public/script.js b/public/script.js index 26509f1..5823c67 100644 --- a/public/script.js +++ b/public/script.js @@ -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); }); diff --git a/views/index.html b/views/index.html index 667e1dc..854ec38 100644 --- a/views/index.html +++ b/views/index.html @@ -57,8 +57,6 @@ - -