var bbukRootPath = "https://api.broadbandavailability.uk/display/"; //2023 BBA bbukInit(); var bbukPostcode; var bbukUPRN; var bbukToken; var bbukAddress; function bbukInit() { bbukPostcode = document.currentScript.getAttribute("data-postcode"); bbukUPRN = document.currentScript.getAttribute("data-uprn"); bbukAddress = document.currentScript.getAttribute("data-address"); bbukToken = document.currentScript.getAttribute("data-token"); bbukRequest = document.currentScript.getAttribute("data-request"); let bbukElement = document.currentScript.getAttribute("data-element"); let link = document.createElement("link"); link.href = bbukRootPath + "css/v1/?v=" + Date.now(); link.type = "text/css"; link.rel = "stylesheet"; link.media = "screen,print"; document.getElementsByTagName("head")[0].appendChild(link); if (!bbukElement || !document.getElementById(bbukElement)) { let bbukUnderlay = document.createElement("div"); bbukUnderlay.id = "bbukUnderlay"; bbukUnderlay.classList.add("bbukUnderlay"); bbukUnderlay.classList.add("bbukHidden"); bbukUnderlay.style["display"] = "none"; bbukUnderlay.setAttribute("onClick", "bbukClose();"); var url = new URL(location.href); var c = url.searchParams.get("c"); bbukInsertFrame(bbukUnderlay); document.body.appendChild(bbukUnderlay); } else { bbukInsertFrame(document.getElementById(bbukElement)); } } function bbukInsertFrame(elem) { elem.innerHTML += '
' + '
' + '' + '' + "
" + "
"; } // put this on the button: var bbukOpenned = false; function bbukHandleOnClick() { let bbukUnderlay = document.getElementById("bbukUnderlay"); bbukUnderlay.classList.remove("bbukHidden"); if (!bbukOpenned) fetch( "https://api.broadbandavailability.uk/subdomains/api/logView/v1/?postcode=" + bbukPostcode + "&uprn=" + bbukUPRN + "&token=" + bbukToken + "&request=" + bbukRequest + "&url=" + encodeURIComponent(location.href) ); bbukOpenned = true; } function bbukClose() { let bbukUnderlay = document.getElementById("bbukUnderlay"); bbukUnderlay.classList.add("bbukHidden"); }