Template:CitationTooltip: differenze tra le versioni
Creata pagina con "<!-- Template:CitationTooltip --> <script> (function () { console.log("🔍 Tooltip citazioni avviato"); const abstractMapByTitle = { "the epistemology of mathematical and statistical modeling: a quiet methodological revolution": ` <strong>Rodgers JL</strong><br> <em>The epistemology of mathematical and statistical modeling: a quiet methodological revolution</em><br> <small><span style="color:#999">Am Psychol, 2010</span></small> <hr>..." |
Nessun oggetto della modifica |
||
Riga 1: | Riga 1: | ||
console.log("🔍 CommonCitationTooltip.js avviato"); | |||
const abstractMapByTitle = { | |||
"the epistemology of mathematical and statistical modeling: a quiet methodological revolution": ` | |||
<strong>Rodgers JL</strong><br> | |||
<em>The epistemology of mathematical and statistical modeling: a quiet methodological revolution</em><br> | |||
<small><span style="color:#999">Am Psychol, 2010</span></small> | |||
<hr> | |||
<div class="citation-popup-abstract"> | |||
Questo articolo propone un cambiamento radicale nella valutazione statistica, suggerendo un approccio epistemologico alternativo. | |||
</div>` | |||
}; | |||
function normalize(text) { | |||
return text.replace(/\s+/g, ' ').trim().toLowerCase(); | |||
} | |||
function findMatchingTitle(refContent) { | |||
const refText = normalize(refContent.textContent || ''); | |||
for (const title in abstractMapByTitle) { | |||
if (refText.includes(normalize(title))) return title; | |||
} | } | ||
return null; | |||
} | |||
function showTooltip(link, content) { | |||
const popup = document.createElement('div'); | |||
popup.className = 'citation-popup-container'; | |||
popup.innerHTML = content; | |||
document.body.appendChild(popup); | |||
const rect = link.getBoundingClientRect(); | |||
popup.style.top = `${rect.bottom + window.scrollY + 10}px`; | |||
popup.style.left = `${rect.left + window.scrollX}px`; | |||
} | |||
function attachTooltipEvents() { | |||
document.querySelectorAll('sup.reference > a').forEach(link => { | |||
link.addEventListener('click', function (e) { | |||
const href = link.getAttribute('href'); | |||
const refId = href && href.slice(1); | |||
const refElement = document.getElementById(refId); | |||
if (!refElement) return; | |||
const matchedTitle = findMatchingTitle(refElement); | |||
if (!matchedTitle) return; | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
document.querySelectorAll('.citation-popup-container').forEach(el => el.remove()); | |||
showTooltip(link, abstractMapByTitle[matchedTitle]); | |||
}); | }); | ||
}); | |||
document.addEventListener('click', function (e) { | |||
if (!e.target.closest('.citation-popup-container') && !e.target.closest('sup.reference')) { | |||
document.querySelectorAll('.citation-popup-container').forEach(p => p.remove()); | |||
} | |||
}); | |||
console.log("✅ Tooltip attivo per citazioni con abstract noti"); | |||
} | |||
function waitForRefs() { | |||
if (document.querySelectorAll('sup.reference > a').length === 0) { | |||
return setTimeout(waitForRefs, 200); | |||
} | } | ||
attachTooltipEvents(); | |||
} | |||
waitForRefs(); | |||
Versione attuale delle 10:57, 25 apr 2025
console.log("🔍 CommonCitationTooltip.js avviato");
const abstractMapByTitle = {
"the epistemology of mathematical and statistical modeling: a quiet methodological revolution": ` Rodgers JL
The epistemology of mathematical and statistical modeling: a quiet methodological revolution
Am Psychol, 2010
Questo articolo propone un cambiamento radicale nella valutazione statistica, suggerendo un approccio epistemologico alternativo.
`
};
function normalize(text) {
return text.replace(/\s+/g, ' ').trim().toLowerCase();
}
function findMatchingTitle(refContent) {
const refText = normalize(refContent.textContent || ); for (const title in abstractMapByTitle) { if (refText.includes(normalize(title))) return title; } return null;
}
function showTooltip(link, content) {
const popup = document.createElement('div'); popup.className = 'citation-popup-container'; popup.innerHTML = content; document.body.appendChild(popup);
const rect = link.getBoundingClientRect(); popup.style.top = `${rect.bottom + window.scrollY + 10}px`; popup.style.left = `${rect.left + window.scrollX}px`;
}
function attachTooltipEvents() {
document.querySelectorAll('sup.reference > a').forEach(link => { link.addEventListener('click', function (e) { const href = link.getAttribute('href'); const refId = href && href.slice(1); const refElement = document.getElementById(refId); if (!refElement) return;
const matchedTitle = findMatchingTitle(refElement); if (!matchedTitle) return;
e.preventDefault(); e.stopPropagation();
document.querySelectorAll('.citation-popup-container').forEach(el => el.remove()); showTooltip(link, abstractMapByTitle[matchedTitle]); }); });
document.addEventListener('click', function (e) { if (!e.target.closest('.citation-popup-container') && !e.target.closest('sup.reference')) { document.querySelectorAll('.citation-popup-container').forEach(p => p.remove()); } });
console.log("✅ Tooltip attivo per citazioni con abstract noti");
}
function waitForRefs() {
if (document.querySelectorAll('sup.reference > a').length === 0) { return setTimeout(waitForRefs, 200); } attachTooltipEvents();
}
waitForRefs();