javascript/external-links.js
// Select anchor tags, filter non gov domains and add style
Select anchor tags, filter non gov domains and add style
Select anchor tags filter non gov domains and add style
function styleExternalLinks() {
    const anchors = document.getElementsByTagName('a');
    const totalAnchors = anchors.length;
    for (let step = 0; step < totalAnchors; step++) {
      const a = anchors[step];
      const isSocialLink = anchorHasClass(a, 'usa-social-link');
      const isLogo = anchorHasClass(a, 'usa-identifier__logo');
      const isPrivate = anchorHasClass(a, 'private-link');
      const domain = matchDomain(a.href);
      const isDoc = domain.includes('docs.google.com') || domain.includes('drive.google.com');
      const isSlack = domain.includes('slack.com');
      const shouldGetIcon = isNonGovDomain(domain)
        && !isSocialLink
        && !isLogo
        && !isDoc
        && !isSlack;
      if (shouldGetIcon) {
        a.className = a.className + ' ' + 'usa-link--external';
        a.setAttribute('title', 'external link"')
      }
    }
  }
function styleExternalLinks ( ) { const anchors = document . getElementsByTagName ( 'a' ) ; const totalAnchors = anchors . length ; for ( let step = 0 ; step < totalAnchors ; step ++ ) { const a = anchors [ step ] ; const isSocialLink = anchorHasClass ( a , 'usa-social-link' ) ; const isLogo = anchorHasClass ( a , 'usa-identifier__logo' ) ; const isPrivate = anchorHasClass ( a , 'private-link' ) ; const domain = matchDomain ( a . href ) ; const isDoc = domain . includes ( 'docs.google.com' ) || domain . includes ( 'drive.google.com' ) ; const isSlack = domain . includes ( 'slack.com' ) ; const shouldGetIcon = isNonGovDomain ( domain ) && ! isSocialLink && ! isLogo && ! isDoc && ! isSlack ; if ( shouldGetIcon ) { a . className = a . className + ' ' + 'usa-link--external' ; a . setAttribute ( 'title' , 'external link"' ) } } }
Select anchor tags, filter non gov domains and add style
Select anchor tags filter non gov domains and add style