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.

36 lines
832 B

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