|
10 | 10 | </div>
|
11 | 11 | </template>
|
12 | 12 |
|
| 13 | +<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script> |
13 | 14 | <script>
|
14 |
| - require.config({ |
15 |
| - paths: { |
16 |
| - 'js-yaml': 'https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min' |
17 |
| - } |
18 |
| - }); |
19 |
| - |
20 |
| - require(['js-yaml'], function (jsyaml) { |
21 |
| - // Function to get last name from full name |
22 |
| - function getLastName(fullName) { |
23 |
| - const nameParts = fullName.trim().split(' '); |
24 |
| - return nameParts[nameParts.length - 1]; |
25 |
| - } |
26 |
| - |
27 |
| - // Function to load the YAML file |
28 |
| - async function loadAuthorData() { |
29 |
| - try { |
30 |
| - const response = await fetch('../../authors.yml'); |
31 |
| - const yamlText = await response.text(); |
32 |
| - window.authorData = jsyaml.load(yamlText); |
33 |
| - initializeAuthors(); |
34 |
| - } catch (error) { |
35 |
| - console.error('Error loading author data:', error); |
| 15 | + initAuthorReveal(); |
| 16 | + |
| 17 | + function initAuthorReveal() { |
| 18 | + require.config({ |
| 19 | + paths: { |
| 20 | + 'js-yaml': 'https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min' |
| 21 | + } |
| 22 | + }); |
| 23 | + |
| 24 | + require(['js-yaml'], function (jsyaml) { |
| 25 | + // Function to get last name from full name |
| 26 | + function getLastName(fullName) { |
| 27 | + const nameParts = fullName.trim().split(' '); |
| 28 | + return nameParts[nameParts.length - 1]; |
36 | 29 | }
|
37 |
| - } |
38 |
| - |
39 |
| - function initializeAuthors() { |
40 |
| - // Find the quarto-title-meta div |
41 |
| - const titleMeta = document.querySelector('.quarto-title-meta'); |
42 |
| - if (!titleMeta) return; |
43 |
| - |
44 |
| - // Get template content |
45 |
| - const template = document.getElementById('authors-template'); |
46 |
| - const authorsSection = template.content.cloneNode(true); |
47 |
| - |
48 |
| - // Get the authors content div from the cloned template |
49 |
| - const authorsContent = authorsSection.querySelector('.authors-content'); |
50 |
| - |
51 |
| - // Update sort to use last name |
52 |
| - const sortedAuthors = [...authorData.authors].sort((a, b) => { |
53 |
| - const lastNameA = getLastName(a.name); |
54 |
| - const lastNameB = getLastName(b.name); |
55 |
| - return lastNameA.localeCompare(lastNameB); |
56 |
| - }); |
57 |
| - |
58 |
| - // Process authors from the data |
59 |
| - sortedAuthors.forEach(author => { |
60 |
| - const authorP = document.createElement('p'); |
61 |
| - |
62 |
| - // Create name span |
63 |
| - const nameSpan = document.createElement('span'); |
64 |
| - nameSpan.className = 'author-name'; |
65 |
| - nameSpan.textContent = author.name; |
66 |
| - authorP.appendChild(nameSpan); |
67 |
| - |
68 |
| - // Add ORCID if present |
69 |
| - if (author.orcid) { |
70 |
| - const orcidLink = document.createElement('a'); |
71 |
| - orcidLink.href = `https://orcid.org/${author.orcid}`; |
72 |
| - orcidLink.className = 'quarto-title-author-orcid'; |
73 |
| - |
74 |
| - const orcidImage = document.createElement('img'); |
75 |
| - orcidImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0d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a4/24bSuoExcJCfAEJihXkWDj3ZAKy9EJGaEo8T0QSxkjSwORsCAuDQCD+QILmD1A9kECEZgxDaEZhICIzGcIyEyOl2RkgwAAhkmC+eAm0TAAAAABJRU5ErkJggg=='; |
76 |
| - orcidLink.appendChild(orcidImage); |
77 |
| - |
78 |
| - authorP.appendChild(orcidLink); |
| 30 | + |
| 31 | + // Function to load the YAML file |
| 32 | + async function loadAuthorData() { |
| 33 | + try { |
| 34 | + // Get base URL from an existing resource we know works (navbar logo) |
| 35 | + const navbarLogo = document.querySelector('.navbar-logo'); |
| 36 | + let baseUrl = ''; |
| 37 | + |
| 38 | + if (navbarLogo && navbarLogo.src) { |
| 39 | + baseUrl = navbarLogo.src.substring(0, navbarLogo.src.lastIndexOf('/assets/')); |
| 40 | + } |
| 41 | + |
| 42 | + // Use the baseUrl to construct the path to authors.yml |
| 43 | + const authorYamlPath = baseUrl + '/authors.yml'; |
| 44 | + |
| 45 | + const response = await fetch(authorYamlPath); |
| 46 | + if (!response.ok) { |
| 47 | + throw new Error(`HTTP error! status: ${response.status}`); |
| 48 | + } |
| 49 | + |
| 50 | + const yamlText = await response.text(); |
| 51 | + window.authorData = jsyaml.load(yamlText); |
| 52 | + initializeAuthors(); |
| 53 | + } catch (error) { |
| 54 | + console.error('Error loading author data:', error); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + function initializeAuthors() { |
| 59 | + // Find the quarto-title-meta div |
| 60 | + const titleMeta = document.querySelector('.quarto-title-meta'); |
| 61 | + if (!titleMeta) { |
| 62 | + return; |
79 | 63 | }
|
80 | 64 |
|
81 |
| - // Add to authors content |
82 |
| - authorsContent.appendChild(authorP); |
83 |
| - |
84 |
| - // Add tippy tooltip with roles if present |
85 |
| - if (author.roles) { |
86 |
| - const tooltipContent = `Roles: ${author.roles.map(r => r.charAt(0).toUpperCase() + r.slice(1)).join(', ')}`; |
87 |
| - tippy(nameSpan, { |
88 |
| - content: tooltipContent, |
89 |
| - allowHTML: true, |
90 |
| - placement: 'bottom', |
91 |
| - arrow: true, |
92 |
| - theme: 'custom' |
93 |
| - }); |
| 65 | + // Get template content |
| 66 | + const template = document.getElementById('authors-template'); |
| 67 | + if (!template) { |
| 68 | + return; |
94 | 69 | }
|
95 |
| - }); |
96 |
| - |
97 |
| - // Create container and insert at the beginning of title meta |
98 |
| - const containerDiv = document.createElement('div'); |
99 |
| - titleMeta.insertBefore(containerDiv, titleMeta.firstChild); |
100 |
| - containerDiv.appendChild(authorsSection); |
101 |
| - |
102 |
| - // Add toggle functionality |
103 |
| - const toggle = document.querySelector('.authors-toggle'); |
104 |
| - const content = document.querySelector('.authors-content'); |
105 |
| - |
106 |
| - toggle.addEventListener('click', () => { |
107 |
| - const isExpanded = toggle.getAttribute('aria-expanded') === 'true'; |
108 |
| - toggle.setAttribute('aria-expanded', !isExpanded); |
109 |
| - content.classList.toggle('is-visible'); |
110 |
| - }); |
111 |
| - |
112 |
| - // Initialize ARIA attributes |
113 |
| - toggle.setAttribute('aria-expanded', 'false'); |
114 |
| - toggle.setAttribute('aria-controls', 'authors-content'); |
115 |
| - content.setAttribute('id', 'authors-content'); |
116 |
| - } |
117 |
| - |
118 |
| - // Start loading when DOM is ready |
119 |
| - if (document.readyState === 'loading') { |
120 |
| - document.addEventListener('DOMContentLoaded', loadAuthorData); |
121 |
| - } else { |
122 |
| - loadAuthorData(); |
123 |
| - } |
124 |
| - }); |
| 70 | + const authorsSection = template.content.cloneNode(true); |
| 71 | + |
| 72 | + // Get the authors content div from the cloned template |
| 73 | + const authorsContent = authorsSection.querySelector('.authors-content'); |
| 74 | + |
| 75 | + // Update sort to use last name |
| 76 | + const sortedAuthors = [...authorData.authors].sort((a, b) => { |
| 77 | + const lastNameA = getLastName(a.name); |
| 78 | + const lastNameB = getLastName(b.name); |
| 79 | + return lastNameA.localeCompare(lastNameB); |
| 80 | + }); |
| 81 | + |
| 82 | + // Process authors from the data |
| 83 | + sortedAuthors.forEach(author => { |
| 84 | + const authorP = document.createElement('p'); |
| 85 | + |
| 86 | + // Create name span |
| 87 | + const nameSpan = document.createElement('span'); |
| 88 | + nameSpan.className = 'author-name'; |
| 89 | + nameSpan.textContent = author.name; |
| 90 | + authorP.appendChild(nameSpan); |
| 91 | + |
| 92 | + // Add ORCID if present |
| 93 | + if (author.orcid) { |
| 94 | + const orcidLink = document.createElement('a'); |
| 95 | + orcidLink.href = `https://orcid.org/${author.orcid}`; |
| 96 | + orcidLink.className = 'quarto-title-author-orcid'; |
| 97 | + |
| 98 | + const orcidImage = document.createElement('img'); |
| 99 | + orcidImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo1N0NEMjA4MDI1MjA2ODExOTk0QzkzNTEzRjZEQTg1NyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDozM0NDOEJGNEZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozM0NDOEJGM0ZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZDN0YxMTc0MDcyMDY4MTE5NUZFRDc5MUM2MUUwNEREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjU3Q0QyMDgwMjUyMDY4MTE5OTRDOTM1MTNGNkRBODU3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+84NovQAAAR1JREFUeNpiZEADy85ZJgCpeCB2QJM6AMQLo4yOL0AWZETSqACk1gOxAQN+cAGIA4EGPQBxmJA0nwdpjjQ8xqArmczw5tMHXAaALDgP1QMxAGqzAAPxQACqh4ER6uf5MBlkm0X4EGayMfMw/Pr7Bd2gRBZogMFBrv01hisv5jLsv9nLAPIOMnjy8RDDyYctyAbFM2EJbRQw+aAWw/LzVgx7b+cwCHKqMhjJFCBLOzAR6+lXX84xnHjYyqAo5IUizkRCwIENQQckGSDGY4TVgAPEaraQr2a4/24bSuoExcJCfAEJihXkWDj3ZAKy9EJGaEo8T0QSxkjSwORsCAuDQCD+QILmD1A9kECEZgxDaEZhICIzGcIyEyOl2RkgwAAhkmC+eAm0TAAAAABJRU5ErkJggg=='; |
| 100 | + orcidLink.appendChild(orcidImage); |
| 101 | + |
| 102 | + authorP.appendChild(orcidLink); |
| 103 | + } |
| 104 | + |
| 105 | + // Add to authors content |
| 106 | + authorsContent.appendChild(authorP); |
| 107 | + |
| 108 | + // Add tippy tooltip with roles if present |
| 109 | + if (author.roles) { |
| 110 | + const tooltipContent = `Roles: ${author.roles.map(r => r.charAt(0).toUpperCase() + r.slice(1)).join(', ')}`; |
| 111 | + tippy(nameSpan, { |
| 112 | + content: tooltipContent, |
| 113 | + allowHTML: true, |
| 114 | + placement: 'bottom', |
| 115 | + arrow: true, |
| 116 | + theme: 'custom' |
| 117 | + }); |
| 118 | + } |
| 119 | + }); |
| 120 | + |
| 121 | + // Create container and insert at the beginning of title meta |
| 122 | + const containerDiv = document.createElement('div'); |
| 123 | + titleMeta.insertBefore(containerDiv, titleMeta.firstChild); |
| 124 | + containerDiv.appendChild(authorsSection); |
| 125 | + |
| 126 | + // Add toggle functionality |
| 127 | + const toggle = document.querySelector('.authors-toggle'); |
| 128 | + const content = document.querySelector('.authors-content'); |
| 129 | + |
| 130 | + if (!toggle || !content) { |
| 131 | + return; |
| 132 | + } |
| 133 | + |
| 134 | + toggle.addEventListener('click', () => { |
| 135 | + const isExpanded = toggle.getAttribute('aria-expanded') === 'true'; |
| 136 | + toggle.setAttribute('aria-expanded', !isExpanded); |
| 137 | + content.classList.toggle('is-visible'); |
| 138 | + }); |
| 139 | + |
| 140 | + // Initialize ARIA attributes |
| 141 | + toggle.setAttribute('aria-expanded', 'false'); |
| 142 | + toggle.setAttribute('aria-controls', 'authors-content'); |
| 143 | + content.setAttribute('id', 'authors-content'); |
| 144 | + } |
| 145 | + |
| 146 | + // Start loading when DOM is ready |
| 147 | + if (document.readyState === 'loading') { |
| 148 | + document.addEventListener('DOMContentLoaded', loadAuthorData); |
| 149 | + } else { |
| 150 | + loadAuthorData(); |
| 151 | + } |
| 152 | + }); |
| 153 | + } |
125 | 154 | </script>
|
0 commit comments