====== Code koha-entpe-2.js ====== /* widget Mirabel */ const container = document.getElementById('mirabel'); document.querySelectorAll('[property="issn"]').forEach(addMirabelLink); function addMirabelLink(node) { var issn = node.innerText.replace(/ +/g, ''); fetch("https://reseau-mirabel.info/api/acces/titres?issn=" + issn) .then(function(response) { if (!response.ok) { throw new Error('HTTP error, status = ' + response.status); } return response.json(); }) .then(function(data) { while (container.firstChild) { container.removeChild(container.firstChild); } if(data.length === 0) { container.innerHTML += 'Pas d\'accès connu au texte intégral en ligne'; } else { var a = document.createElement('a'); a.href = "https://reseau-mirabel.info/revue/issn/" + issn; a.title = "Information fournie par Mir@bel : cliquer pour voir le détail des " + data.length + " accès disponibles (texte intégral, sommaires, résumés, indexation)"; a.innerHTML = ''; container.insertAdjacentElement('beforeend', a); container.innerHTML += ' Texte intégral des articles :'; for(var i = 0; i < data.length; i++) { if(data[i].contenu === 'Intégral') { var div = document.createElement('div'); var lien = document.createElement('a'); lien.id = data[i].id; lien.href = data[i].url; lien.textContent = data[i].ressource; div.appendChild(lien); div.insertAdjacentText('beforeend',', accès ' + data[i].diffusion + ', ' + fdate(data[i].datedebut,data[i].datefin)); div.setAttribute('class','results_summary mirabel'); div.setAttribute('style','padding: 2px 0 0 20px'); container.appendChild(div); } } } }); } function fdate(d,f){ if(d!=null && f !=null) { return 'de ' + d + ' à ' + f; } else { if(d!=null) { return 'depuis ' + d; } else { return 'jusqu\'à ' + f; } } } /* fin du widget Mirabel */