commit e80d04006d6e1a5fd134893e02eb0b044f9a8867 parent f8fc4ea53a0e0e388ca8dcb7b05886ea7bfdf9a6 Author: Florian Kaldowski <flokX@users.noreply.github.com> Date: Tue, 2 Apr 2019 16:39:23 +0200 Filter names and urls I (see #6) Diffstat:
M | admin/main.js | | | 15 | +++++++++++---- |
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/admin/main.js b/admin/main.js @@ -10,11 +10,18 @@ $('button#add-shortlink').click(function (event) { $.post('index.php?add', { name: $('input#name').val(), link: $('input#link').val() - }, function () { - $('input#name').val(''); - $('input#link').val(''); - getCharts(); + }, function (data) { + if (data === '{"status": "successful"}') { + $('input#name').val(''); + $('input#link').val(''); + getCharts(); + } else if (data === '{"status": "unvalid-url"}') { + document.getElementById('status').innerHTML = '<div class="alert alert-danger" role="alert">Unvalid URL. Please provide a valid URL.</div>'; + } else { + document.getElementById('status').innerHTML = '<div class="alert alert-danger" role="alert">Error. Please try again.</div>'; + } }); + $('div#spinner').hide(); }); $('a#refresh').click(function (event) { event.preventDefault();