1window.addEventListener("DOMContentLoaded", function () { 2 let navigation = JSINFO["navigation"]; 3 let acronymPageProtection = "pp"; 4 let acronymLowQualityPage = "lqpp"; 5 let acronymLatePublication = "lpp"; 6 document.querySelectorAll(`[data-${acronymPageProtection}-link="warning"], [data-${acronymPageProtection}-link="login"]`).forEach(element => { 7 let tooltipHtml = ""; 8 let linkType = element.dataset.ppLink; 9 let protectionSourceType = element.dataset.ppSource; 10 let showTooltip = false; 11 switch (linkType) { 12 case "warning": 13 if (protectionSourceType === acronymLowQualityPage) { 14 showTooltip = true; 15 tooltipHtml = `<h4>Warning: Low Quality Page</h4> 16<p>This page has been detected as being of low quality.</p>`; 17 if (element.hasAttribute("title")) { 18 tooltipHtml += "<p>Description: " + element.getAttribute("title") + "</p>"; 19 } 20 } 21 break 22 case "login": 23 if (navigation === "anonymous") { 24 showTooltip = true; 25 element.addEventListener('click', function (event) { 26 // not pointer-events: none because we need to show a tooltip 27 event.preventDefault(); 28 }); 29 switch (protectionSourceType) { 30 case acronymLowQualityPage: 31 tooltipHtml = `<h4>Login Required</h4> 32<p>This page has been detected as being of low quality. To follow this link, you need to log in.</p>`; 33 break; 34 case acronymLatePublication: 35 tooltipHtml = `<h4>Login Required</h4> 36<p>To follow this link, you need to log in (${acronymLatePublication})</p>`; 37 break; 38 } 39 40 } 41 break; 42 43 } 44 if (showTooltip) { 45 // An element may already have a tooltip 46 let tooltip = bootstrap.Tooltip.getInstance(element); 47 if (tooltip != null) { 48 tooltip.dispose(); 49 } 50 element.setAttribute("title", tooltipHtml); 51 new bootstrap.Tooltip(element, { 52 html: true, 53 placement: "top", 54 customClass: acronymPageProtection 55 }); 56 } 57 }); 58}); 59