Loading resources/javascript/xml_2_html.js +122 −0 Original line number Diff line number Diff line Loading @@ -545,7 +545,33 @@ document.addEventListener('DOMContentLoaded', function() { }); }); function deactivateAllFilters(exceptBtnId) { const filters = [ { btnId: 'btn-filter-figures', injectedId: null }, { btnId: 'btn-filter-metadata', injectedId: 'injected-metadata' }, { btnId: 'btn-filter-bibliometrics',injectedId: 'injected-bibliometrics' }, ]; filters.forEach(({ btnId, injectedId }) => { if (btnId === exceptBtnId) return; const btn = document.getElementById(btnId); if (btn) btn.classList.remove('active'); if (injectedId) { const injected = document.getElementById(injectedId); if (injected) injected.remove(); } }); // Restaurer l'affichage de base document.querySelector('.article-wrap').querySelectorAll('*').forEach(el => { el.style.removeProperty('display'); }); } function toggleFiguresFilter() { deactivateAllFilters('btn-filter-figures'); const articleWrap = document.querySelector('.article-wrap'); const btn = document.getElementById('btn-filter-figures'); const label = document.getElementById('filter-label'); Loading Loading @@ -580,6 +606,102 @@ articleWrap.querySelectorAll('*').forEach(el => { } } async function toggleBibliometrics() { deactivateAllFilters('btn-filter-bibliometrics'); const articleWrap = document.querySelector('.article-wrap'); const btn = document.getElementById('btn-filter-bibliometrics'); const isActive = btn.classList.toggle('active'); if (isActive) { articleWrap.querySelectorAll('p, table.linguistic, ul.index-unordered, h1, h2, h3, figure, section').forEach(el => { el.style.display = 'none'; }); let injected = document.getElementById('injected-bibliometrics'); if (!injected) { injected = document.createElement('div'); injected.id = 'injected-bibliometrics'; injected.style.cssText = 'display:block; padding: 1em;'; injected.innerHTML = '<p>Chargement…</p>'; articleWrap.appendChild(injected); // Données statiques du DOM const published = document.querySelector('.item.published .value')?.innerText.trim() ?? 'N/A'; const section = document.querySelector('.item.issue .sub_item .value')?.innerText.trim() ?? 'N/A'; const keywords = document.querySelector('.item.keywords .value')?.innerText.trim() ?? 'N/A'; const galleys = [...document.querySelectorAll('.galleys_links a')].map(a => a.innerText.trim()).join(', ') || 'N/A'; // Données dynamiques via API const match = window.location.pathname.match(/article\/view\/(\d+)/); const articleId = match ? match[1] : null; let statsHTML = '<li><em>Statistiques indisponibles.</em></li>'; if (articleId) { try { const res = await fetch(`/index.php/mj/api/v1/stats/publications/${articleId}`); const data = await res.json(); statsHTML = ` <li><strong>Vues du résumé :</strong> ${data.abstractViews ?? 0}</li> <li><strong>Vues HTML :</strong> ${data.htmlViews ?? 0}</li> <li><strong>Vues PDF :</strong> ${data.pdfViews ?? 0}</li> <li><strong>Autres téléchargements :</strong> ${data.otherViews ?? 0}</li> <li><strong>Total galley :</strong> ${data.galleyViews ?? 0}</li>`; } catch (e) {} } injected.innerHTML = ` <h2>Bibliométrie</h2> <h3>Statistiques de consultation</h3> <ul>${statsHTML}</ul> <h3>Informations de publication</h3> <ul> <li><strong>Publié le :</strong> ${published}</li> <li><strong>Rubrique :</strong> ${section}</li> <li><strong>Mots-clés :</strong> ${keywords}</li> <li><strong>Formats disponibles :</strong> ${galleys}</li> </ul>`; } else { injected.style.display = 'block'; } } else { const injected = document.getElementById('injected-bibliometrics'); if (injected) injected.remove(); articleWrap.querySelectorAll('*').forEach(el => el.style.removeProperty('display')); } } function toggleMetadataFilter() { deactivateAllFilters('btn-filter-metadata'); const articleWrap = document.querySelector('.article-wrap'); const btn = document.getElementById('btn-filter-metadata'); const isActive = btn.classList.toggle('active'); if (isActive) { articleWrap.querySelectorAll('p, table.linguistic, ul.index-unordered, h1, h2, h3, figure, section').forEach(el => { el.style.display = 'none'; }); const metaContent = document.querySelector('#article-meta'); if (metaContent && !document.getElementById('injected-metadata')) { const metaClone = metaContent.cloneNode(true); metaClone.id = 'injected-metadata'; metaClone.style.cssText = 'display:block; padding: 1em; background: var(--bg, #fff);'; articleWrap.appendChild(metaClone); } else if (document.getElementById('injected-metadata')) { document.getElementById('injected-metadata').style.display = 'block'; } } else { const injected = document.getElementById('injected-metadata'); if (injected) injected.remove(); articleWrap.querySelectorAll('*').forEach(el => { el.style.removeProperty('display'); }); } } function openGalleyIframe() { // Récupère le lien galley présent dans la page const galleyLink = document.querySelector('.galleys_links .obj_galley_link'); Loading Loading
resources/javascript/xml_2_html.js +122 −0 Original line number Diff line number Diff line Loading @@ -545,7 +545,33 @@ document.addEventListener('DOMContentLoaded', function() { }); }); function deactivateAllFilters(exceptBtnId) { const filters = [ { btnId: 'btn-filter-figures', injectedId: null }, { btnId: 'btn-filter-metadata', injectedId: 'injected-metadata' }, { btnId: 'btn-filter-bibliometrics',injectedId: 'injected-bibliometrics' }, ]; filters.forEach(({ btnId, injectedId }) => { if (btnId === exceptBtnId) return; const btn = document.getElementById(btnId); if (btn) btn.classList.remove('active'); if (injectedId) { const injected = document.getElementById(injectedId); if (injected) injected.remove(); } }); // Restaurer l'affichage de base document.querySelector('.article-wrap').querySelectorAll('*').forEach(el => { el.style.removeProperty('display'); }); } function toggleFiguresFilter() { deactivateAllFilters('btn-filter-figures'); const articleWrap = document.querySelector('.article-wrap'); const btn = document.getElementById('btn-filter-figures'); const label = document.getElementById('filter-label'); Loading Loading @@ -580,6 +606,102 @@ articleWrap.querySelectorAll('*').forEach(el => { } } async function toggleBibliometrics() { deactivateAllFilters('btn-filter-bibliometrics'); const articleWrap = document.querySelector('.article-wrap'); const btn = document.getElementById('btn-filter-bibliometrics'); const isActive = btn.classList.toggle('active'); if (isActive) { articleWrap.querySelectorAll('p, table.linguistic, ul.index-unordered, h1, h2, h3, figure, section').forEach(el => { el.style.display = 'none'; }); let injected = document.getElementById('injected-bibliometrics'); if (!injected) { injected = document.createElement('div'); injected.id = 'injected-bibliometrics'; injected.style.cssText = 'display:block; padding: 1em;'; injected.innerHTML = '<p>Chargement…</p>'; articleWrap.appendChild(injected); // Données statiques du DOM const published = document.querySelector('.item.published .value')?.innerText.trim() ?? 'N/A'; const section = document.querySelector('.item.issue .sub_item .value')?.innerText.trim() ?? 'N/A'; const keywords = document.querySelector('.item.keywords .value')?.innerText.trim() ?? 'N/A'; const galleys = [...document.querySelectorAll('.galleys_links a')].map(a => a.innerText.trim()).join(', ') || 'N/A'; // Données dynamiques via API const match = window.location.pathname.match(/article\/view\/(\d+)/); const articleId = match ? match[1] : null; let statsHTML = '<li><em>Statistiques indisponibles.</em></li>'; if (articleId) { try { const res = await fetch(`/index.php/mj/api/v1/stats/publications/${articleId}`); const data = await res.json(); statsHTML = ` <li><strong>Vues du résumé :</strong> ${data.abstractViews ?? 0}</li> <li><strong>Vues HTML :</strong> ${data.htmlViews ?? 0}</li> <li><strong>Vues PDF :</strong> ${data.pdfViews ?? 0}</li> <li><strong>Autres téléchargements :</strong> ${data.otherViews ?? 0}</li> <li><strong>Total galley :</strong> ${data.galleyViews ?? 0}</li>`; } catch (e) {} } injected.innerHTML = ` <h2>Bibliométrie</h2> <h3>Statistiques de consultation</h3> <ul>${statsHTML}</ul> <h3>Informations de publication</h3> <ul> <li><strong>Publié le :</strong> ${published}</li> <li><strong>Rubrique :</strong> ${section}</li> <li><strong>Mots-clés :</strong> ${keywords}</li> <li><strong>Formats disponibles :</strong> ${galleys}</li> </ul>`; } else { injected.style.display = 'block'; } } else { const injected = document.getElementById('injected-bibliometrics'); if (injected) injected.remove(); articleWrap.querySelectorAll('*').forEach(el => el.style.removeProperty('display')); } } function toggleMetadataFilter() { deactivateAllFilters('btn-filter-metadata'); const articleWrap = document.querySelector('.article-wrap'); const btn = document.getElementById('btn-filter-metadata'); const isActive = btn.classList.toggle('active'); if (isActive) { articleWrap.querySelectorAll('p, table.linguistic, ul.index-unordered, h1, h2, h3, figure, section').forEach(el => { el.style.display = 'none'; }); const metaContent = document.querySelector('#article-meta'); if (metaContent && !document.getElementById('injected-metadata')) { const metaClone = metaContent.cloneNode(true); metaClone.id = 'injected-metadata'; metaClone.style.cssText = 'display:block; padding: 1em; background: var(--bg, #fff);'; articleWrap.appendChild(metaClone); } else if (document.getElementById('injected-metadata')) { document.getElementById('injected-metadata').style.display = 'block'; } } else { const injected = document.getElementById('injected-metadata'); if (injected) injected.remove(); articleWrap.querySelectorAll('*').forEach(el => { el.style.removeProperty('display'); }); } } function openGalleyIframe() { // Récupère le lien galley présent dans la page const galleyLink = document.querySelector('.galleys_links .obj_galley_link'); Loading