with all the HTML until the end marker is found
let iterNode = pNode.nextSibling;
let nodesToAppend = []
while (iterNode != null) {
if (iterNode.innerHTML.indexOf(TOGGLE_END_MARKER) == -1) {
nodesToAppend.push(iterNode);
iterNode = iterNode.nextSibling;
} else {
iterNode.parentNode.removeChild(iterNode);
iterNode = null;
}
}
nodesToAppend.forEach(n => {togglableContent.appendChild(n);});
pNode.parentNode.removeChild(pNode);
togglableContent.style = yellowBoxStyle;
// Initially hide all the togglable content
togglableContent.style.display = "none";
}
});
}
function renameOneTrustHeaderTags() {
const ONETRUST_CLASS_SELECTOR = '.otnotice'
const punctuationRegex = /[ '"`.,\/\\><#!$%?@\^&\*+;:{}=\~()-]/g;
const allHeaderTagsQuerySelector = 'h1, h2, h3, h4, h5, h6';
const regexForNumericPrefix = /^[0-9]+[.][0-9]* /;
const regexForDuplicateUnderscores = /[_]{2,}/g;
const regexForLeadingUnderscores = /^_+/g;
const regexForTrailingUnderscores = /_+$/g;
document.querySelector(ONETRUST_CLASS_SELECTOR).querySelectorAll(allHeaderTagsQuerySelector).forEach(
(node) => {
let newNameForTag = node.textContent
.replace(regexForNumericPrefix, "")
.replace(punctuationRegex, "_")
.replace(regexForDuplicateUnderscores, "_")
.replace(regexForLeadingUnderscores, "")
.replace(regexForTrailingUnderscores, "")
.toLowerCase();
node.setAttribute(
"id",
newNameForTag
);
}
);
}
function replaceUpdatedDate() {
if (window.last_updated != null) {
const element = document.querySelector("#page_title");
if (element) {
const nextSibling = element.nextSibling;
if(nextSibling) {
nextSibling.textContent = window.last_updated;
}
}
}
}
(function fetchPolicyDocumentFromOneTrust() {
OneTrust.NoticeApi.Initialized.then(function() {
page_info = document.getElementById('vimeo_onetrust_page_src');
url = page_info.dataset.url;
production = page_info.dataset.prod;
OneTrust.NoticeApi.LoadNotices([url], production)
.then(renameOneTrustHeaderTags)
.then(replaceUpdatedDate)
.then(drawYellowBoxAroundNotices)
.then(addTogglableContent)
.then(updateFocusToHashAnchor);
});
})();