document.documentElement.classList.add('script-active');
document.documentElement.classList.remove('script-inactive');
const xml_base_pub = document.documentElement.getAttribute("data-xml-base-pub");

function checkLinkHref(elms) {
  //console.log("checkLinkHref");
  for (let a of elms) {
    //console.log(a.href);
    fetch(a.href)
    .then(function(response) {
      //console.log("checkLinkHref II");
      if (response.ok)
        return;
      //console.log("checkLinkHref III");
      a.classList.remove("enabled");
      a.classList.add("disabled");
    })
    .catch(function(err) {
      //console.log("checkLinkHref");
      console.log(a.href);
      console.log(err);
    }) ;
  }
}

// Firefox 56+ doesn't fire that one in xslt situation: document.addEventListener("DOMContentLoaded", function(event) { console.log("DOM fully loaded and parsed"); });
var addlink;
document.onreadystatechange = function () {
  if(addlink !== undefined)
    return;
  checkLinkHref(document.getElementsByClassName("enabled"));
}
