actor.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. function autoButtons(elms) {
  2. console.log('actor.js:autoButtons ' + elms.length);
  3. for (var i = elms.length - 1; i >= 0 ; i--) {
  4. const elm = elms[i];
  5. // https://stackoverflow.com/a/26946264/349514
  6. elm.addEventListener('input', function (evt) {
  7. this.form.submit();
  8. });
  9. }
  10. }
  11. document.documentElement.classList.add('script-active');
  12. document.documentElement.classList.remove('script-inactive');
  13. const xml_base_pub = document.documentElement.getAttribute("data-xml-base-pub");
  14. // make http and geo URIs (RFC 5870) clickable + microformat
  15. function clickableTextLinks(elmsRendered) {
  16. console.log('actor.js:clickableTextLinks');
  17. for (var i = elmsRendered.length - 1; i >= 0 ; i--) {
  18. const elm = elmsRendered[i];
  19. elm.innerHTML = elm.innerHTML
  20. .replace(/(https?:\/\/([^ \t\r\n"'<]+[^ \t\r\n"'<.,;:)]))/gi, '<a rel="noreferrer" title="WWW" class="http" href="$1">$2</a>')
  21. // https://alanstorm.com/url_regex_explained/ \b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))
  22. // .replace(/\b(([\w-]+:\/\/?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/)))/gi, '<a rel="noreferrer" class="http" href="$1">$1</a>')
  23. .replace(/@([a-z0-9._-]+)@([a-z0-9._-]+)/gi, '<a rel="webfinger" title="Webfinger" class="http" href="https://$2/.well-known/webfinger?resource=acct:$1@$2">@$1@$2</a>')
  24. .replace(/geo:(-?\d+.\d+),(-?\d+.\d+)(\?z=(\d+))?/gi, '<a class="geo" href="https://opentopomap.org/#marker=12/$1/$2" title="zoom=$4">geo:<span class="latitude">$1</span>,<span class="longitude">$2</span>$3</a>')
  25. .replace(/(#RFC(\d+)(#\S*[0-9a-z])?)/gi, '<a class="rfc" href="https://tools.ietf.org/html/rfc$2$3" title="RFC $2">$1</a>')
  26. .replace(/(urn:ietf:rfc:(\d+)(#\S*[0-9a-z])?)/gi, '<a class="rfc" href="https://tools.ietf.org/html/rfc$2$3" title="RFC $2">$1</a>')
  27. .replace(/(urn:isbn:([0-9-]+)(#\S*[0-9a-z])?)/gi, '<a class="isbn" href="https://de.wikipedia.org/wiki/Spezial:ISBN-Suche?isbn=$2" title="ISBN $2">$1</a>')
  28. .replace(/(urn:ean:([0-9-]+)(#\S*[0-9a-z])?)/gi, '<a class="ean" href="https://www.ean-suche.de/?q=$2" title="EAN $2">$1</a>')
  29. .replace(/(CVE-[0-9-]+-[0-9]+)/gi, '<a class="cve" href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=$1">$1</a>');
  30. }
  31. }
  32. autoButtons(document.querySelectorAll("[role='button'] input[type='checkbox']"));
  33. clickableTextLinks(document.getElementsByClassName('clickable'));