window.addEventListener("DOMContentLoaded", function () { let navigation = JSINFO["navigation"]; let acronymPageProtection = "pp"; let acronymLowQualityPage = "lqpp"; let acronymLatePublication = "lpp"; document.querySelectorAll(`[data-${acronymPageProtection}-link="warning"], [data-${acronymPageProtection}-link="login"]`).forEach(element => { let tooltipHtml = ""; let linkType = element.dataset.ppLink; let protectionSourceType = element.dataset.ppSource; let showTooltip = false; switch (linkType) { case "warning": if (protectionSourceType === acronymLowQualityPage) { showTooltip = true; tooltipHtml = `

Warning: Low Quality Page

This page has been detected as being of low quality.

`; if (element.hasAttribute("title")) { tooltipHtml += "

Description: " + element.getAttribute("title") + "

"; } } break case "login": if (navigation === "anonymous") { showTooltip = true; element.addEventListener('click', function (event) { // not pointer-events: none because we need to show a tooltip event.preventDefault(); }); switch (protectionSourceType) { case acronymLowQualityPage: tooltipHtml = `

Login Required

This page has been detected as being of low quality. To follow this link, you need to log in.

`; break; case acronymLatePublication: tooltipHtml = `

Login Required

To follow this link, you need to log in (${acronymLatePublication})

`; break; } } break; } if (showTooltip) { // An element may already have a tooltip let tooltip = bootstrap.Tooltip.getInstance(element); if (tooltip != null) { tooltip.dispose(); } element.setAttribute("title", tooltipHtml); new bootstrap.Tooltip(element, { html: true, placement: "top", customClass: acronymPageProtection }); } }); });