1const citationsContainer = document.querySelector('.citations-container'); 2const citationsLoader = document.querySelector('#citations-loader'); 3const citationsImagePath = citationsContainer.getAttribute('data-image-path'); 4const citationUrl = citationsContainer.getAttribute('data-citations-url'); 5const citationProvider = citationsContainer.getAttribute('data-citations-provider'); 6const citationShowTotal = citationsContainer.getAttribute('data-citations-total'); 7const citationShowList = citationsContainer.getAttribute('data-citations-list'); 8const showGoogle = citationsContainer.getAttribute('data-show-google'); 9const showPmc = citationsContainer.getAttribute('data-show-pmc'); 10 11fetch(citationUrl, { 12 method: 'GET', 13}).then(function (response) { 14 if (response.ok) { 15 return response.json(); 16 } else 17 throw new Error('Error getting API Data!'); 18}).then((data) => { 19 displayTotalContent(data.content); 20 displayListContent(data.content); 21 citationsLoader.style.display = 'none'; 22}).catch(error => { 23 citationsLoader.style.display = 'none'; 24 console.log(error); 25}); 26 27function displayTotalContent(data) { 28 if (citationProvider && citationShowTotal) { 29 let crossrefTotal = document.querySelector('.citations-count-crossref'); 30 let scopusTotal = document.querySelector('.citations-count-scopus'); 31 let gridColumns = "1fr"; 32 switch (citationProvider) { 33 case 'crossref': 34 crossrefTotal.style.display = 'block'; 35 crossrefTotal.querySelector('.badge_total').innerText = data["crossref_count"] ? data["crossref_count"] : 0; 36 break; 37 case 'scopus': 38 scopusTotal.style.display = 'block'; 39 scopusTotal.querySelector('.badge_total').innerText = data["scopus_count"] ? data["scopus_count"] : 0; 40 break; 41 case 'all': 42 crossrefTotal.style.display = 'block'; 43 scopusTotal.style.display = 'block'; 44 crossrefTotal.querySelector('.badge_total').innerText = data["crossref_count"] ? data["crossref_count"] : 0; 45 scopusTotal.querySelector('.badge_total').innerText = data["scopus_count"] ? data["scopus_count"] : 0; 46 gridColumns += ' 1fr'; 47 break; 48 } 49 if (showGoogle === "1") { 50 document.querySelector('.citations-count-google').style.display = 'block'; 51 gridColumns += ' 1fr'; 52 } 53 if (showPmc === "1") { 54 document.querySelector('.citations-count-pmc').style.display = 'block'; 55 document.querySelector('.citations-count-pmc').querySelector('.badge_total').innerText = data["pmc_count"] ? data["pmc_count"] : 0; 56 gridColumns += ' 1fr'; 57 } 58 document.querySelector('.citations-count').style.gridTemplateColumns = gridColumns; 59 if (gridColumns.length === 3) { 60 document.querySelector('.citations-count').querySelector('img').style.maxWidth = '50%'; 61 } 62 } 63} 64 65function displayListContent(data) { 66 if (citationShowList) { 67 let list = data[citationProvider + '_list']; 68 if (list && list.length > 0) 69 for (let item of list) { 70 document.querySelector('.citations-list').appendChild(createListElement(item)); 71 } 72 } 73} 74 75function createListElement(item) { 76 let outerDiv = document.createElement('div'); 77 let img = document.createElement("img"); 78 img.src = citationsImagePath + '/' + item['type'] + '.png'; 79 img.alt = item['type'] + " Logo"; 80 /*outerDiv.appendChild(img);*/ 81 let author = document.createElement('div'); 82 author.innerHTML = item['authors'] + ' (' + item['year'] + ')'; 83 outerDiv.appendChild(author); 84 let title = document.createElement('span'); 85 title.style.fontWeight = 'bold'; 86 title.innerHTML = item['article_title'] + '. '; 87 outerDiv.append(title); 88 if (item['journal_title'] && item['journal_title'] !== '') 89 outerDiv.append(item['journal_title'] + ', '); 90 if (item['volume'] && item['volume'] !== '') { 91 outerDiv.append(" " + item['volume']); 92 if (item['issue'] && item['issue'] !== '') 93 outerDiv.append("(" + item['issue'] + '), '); 94 else 95 outerDiv.append(", "); 96 } 97 if (item['first_page'] && item['first_page'] !== ' :') 98 outerDiv.append(item['first_page'] + '.'); 99 outerDiv.appendChild(document.createElement('br')); 100 let doi = document.createElement('a'); 101 doi.href = "https://doi.org/" + item['doi']; 102 doi.target = "_blank"; 103 doi.rel = "noreferrer"; 104 doi.innerText = item['doi']; 105 outerDiv.append(doi); 106 return outerDiv; 107} 108
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.