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 form = document.getElementById('shorten-form');
var urlBox = form.elements[0]; var box = form.elements[0];
var link = document.getElementById('link'); var link = document.getElementById('link');
var shrBox = document.getElementById('shortened'); var shrt = document.getElementById('shortened');
function displayShortenedUrl(response) { function d(data) {
link.textContent = response.data.url; link.textContent = data.url;
link.setAttribute( link.setAttribute('href', data.url);
'href', response.data.url shrt.style.opacity = '1';
); box.value = '';
shrBox.style.opacity = '1';
urlBox.value = '';
} }
form.addEventListener('submit', function(e) { form.addEventListener('submit', function(e) {
e.preventDefault(); 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>
</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> <script src="public/script.js"></script>
</body> </body>
</html> </html>