You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
890 B

  1. function openLinkModal() {
  2. $('#addLinkModal').modal('show');
  3. }
  4. function refreshPage() {
  5. window.location.reload();
  6. }
  7. function addUrl() {
  8. $("#link-btn").prop("disabled", true);
  9. url = $('#link-form').val();
  10. if (url.trim().length === 0) {
  11. showError('URL is required');
  12. return false;
  13. }
  14. $.ajax({
  15. url: '/add',
  16. method: 'POST',
  17. data: { "url": url },
  18. success: function(data) {
  19. $('#link-form').val('');
  20. $("#link-btn").prop("disabled", false);
  21. if (data !== 'Error')
  22. window.location.reload();
  23. else
  24. showError('URL cannot be empty');
  25. }
  26. });
  27. }
  28. function showError(error) {
  29. $('#error-alert').text(error);
  30. $('#error-alert').show();
  31. }
  32. $('#addLinkModal').on('shown.bs.modal', function () {
  33. $('#link-form').trigger('focus');
  34. });