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:
<!-- Template:CitationTooltip -->
console.log("🔍 CommonCitationTooltip.js avviato");
<script>
(function () {
  console.log("🔍 Tooltip citazioni avviato");


  const abstractMapByTitle = {
const abstractMapByTitle = {
    "the epistemology of mathematical and statistical modeling: a quiet methodological revolution": `
  "the epistemology of mathematical and statistical modeling: a quiet methodological revolution": `
      <strong>Rodgers JL</strong><br>
    <strong>Rodgers JL</strong><br>
      <em>The epistemology of mathematical and statistical modeling: a quiet methodological revolution</em><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>
    <small><span style="color:#999">Am Psychol, 2010</span></small>
      <hr>
    <hr>
      <div class="citation-popup-abstract">
    <div class="citation-popup-abstract">
        Questo articolo propone un cambiamento radicale nella valutazione statistica, suggerendo un approccio epistemologico alternativo.
      Questo articolo propone un cambiamento radicale nella valutazione statistica, suggerendo un approccio epistemologico alternativo.
      </div>`
    </div>`
  };
};


  function normalize(text) {
function normalize(text) {
    return text.replace(/\s+/g, ' ').trim().toLowerCase();
  return text.replace(/\s+/g, ' ').trim().toLowerCase();
  }
}


  function findMatchingTitle(refContent) {
function findMatchingTitle(refContent) {
    const refText = normalize(refContent.textContent || '');
  const refText = normalize(refContent.textContent || '');
    for (const title in abstractMapByTitle) {
  for (const title in abstractMapByTitle) {
      if (refText.includes(normalize(title))) return title;
    if (refText.includes(normalize(title))) return title;
    }
    return null;
   }
   }
  return null;
}


  function showTooltip(link, content) {
function showTooltip(link, content) {
    const popup = document.createElement('div');
  const popup = document.createElement('div');
    popup.className = 'citation-popup-container';
  popup.className = 'citation-popup-container';
    popup.innerHTML = content;
  popup.innerHTML = content;
    document.body.appendChild(popup);
  document.body.appendChild(popup);


    const rect = link.getBoundingClientRect();
  const rect = link.getBoundingClientRect();
    popup.style.top = `${rect.bottom + window.scrollY + 10}px`;
  popup.style.top = `${rect.bottom + window.scrollY + 10}px`;
    popup.style.left = `${rect.left + window.scrollX}px`;
  popup.style.left = `${rect.left + window.scrollX}px`;
  }
}


  function attachTooltipEvents() {
function attachTooltipEvents() {
    document.querySelectorAll('sup.reference > a').forEach(link => {
  document.querySelectorAll('sup.reference > a').forEach(link => {
      link.addEventListener('click', function (e) {
    link.addEventListener('click', function (e) {
        const href = link.getAttribute('href');
      const href = link.getAttribute('href');
        const refId = href && href.slice(1);
      const refId = href && href.slice(1);
        const refElement = document.getElementById(refId);
      const refElement = document.getElementById(refId);
        if (!refElement) return;
      if (!refElement) return;


        const matchedTitle = findMatchingTitle(refElement);
      const matchedTitle = findMatchingTitle(refElement);
        if (!matchedTitle) return;
      if (!matchedTitle) return;


        e.preventDefault();
      e.preventDefault();
        e.stopPropagation();
      e.stopPropagation();


        document.querySelectorAll('.citation-popup-container').forEach(el => el.remove());
      document.querySelectorAll('.citation-popup-container').forEach(el => el.remove());
        showTooltip(link, abstractMapByTitle[matchedTitle]);
      showTooltip(link, abstractMapByTitle[matchedTitle]);
      });
     });
     });
  });


    document.addEventListener('click', function (e) {
  document.addEventListener('click', function (e) {
      if (!e.target.closest('.citation-popup-container') && !e.target.closest('sup.reference')) {
    if (!e.target.closest('.citation-popup-container') && !e.target.closest('sup.reference')) {
        document.querySelectorAll('.citation-popup-container').forEach(p => p.remove());
      document.querySelectorAll('.citation-popup-container').forEach(p => p.remove());
      }
    }
    });
  });


    console.log("✅ Tooltip attivo per citazioni con abstract noti");
  console.log("✅ Tooltip attivo per citazioni con abstract noti");
  }
}


  function waitForRefs() {
function waitForRefs() {
    if (document.querySelectorAll('sup.reference > a').length === 0) {
  if (document.querySelectorAll('sup.reference > a').length === 0) {
      return setTimeout(waitForRefs, 200);
    return setTimeout(waitForRefs, 200);
    }
    attachTooltipEvents();
   }
   }
  attachTooltipEvents();
}


  waitForRefs();
waitForRefs();
})();
</script>
 
<style>
.citation-popup-container {
  position: absolute;
  background: white;
  padding: 12px;
  max-width: 28em;
  box-shadow: 0 0 30px rgba(0,0,0,0.3);
  border-radius: 8px;
  font-size: 90%;
  z-index: 999;
}
.citation-popup-abstract {
  margin-top: 8px;
  color: #333;
}
</style>

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();