Contains the Concourse pipeline definition for building a line-server container
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.

39 lines
1.2 KiB

  1. document.getElementById('shorturl').addEventListener('click', function (e) {
  2. e.preventDefault();
  3. if (e.target.href !== "") return;
  4. xhr = new XMLHttpRequest();
  5. xhr.open("GET", e.target.dataset.url, true);
  6. xhr.setRequestHeader('Accept', 'application/json');
  7. xhr.onreadystatechange = function () {
  8. if (xhr.readyState === 4) {
  9. var resp = JSON.parse(xhr.responseText);
  10. if (xhr.status === 200 && resp.error == null) {
  11. e.target.innerText = resp.shortUrl;
  12. e.target.href = resp.shortUrl;
  13. e.target.setAttribute('aria-label', 'Click to copy into clipboard')
  14. } else {
  15. e.target.setAttribute('aria-label', resp.error)
  16. }
  17. }
  18. };
  19. xhr.send();
  20. });
  21. var clipboard = new Clipboard("#shorturl", {
  22. text: function (trigger) {
  23. if (trigger.href == null) return;
  24. return trigger.href;
  25. }
  26. });
  27. clipboard.on('success', function (e) {
  28. e.trigger.setAttribute('aria-label', 'Successfully copied')
  29. });
  30. clipboard.on('error', function (e) {
  31. e.trigger.setAttribute('aria-label', 'Your browser does not support coping to clipboard')
  32. });