-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmyst.html
222 lines (188 loc) · 10.1 KB
/
myst.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<script>
document.addEventListener("DOMContentLoaded", function () {
// Check if the current URL contains '/notebooks/'
if (window.location.pathname.includes('/notebooks/')) {
console.log("Subpage detected. Hiding the banner.");
// Select the element with the class 'quarto-title-banner page-columns page-full'
var titleBanner = document.querySelector(".quarto-title-banner.page-columns.page-full");
// If the element exists, hide it
if (titleBanner) {
titleBanner.style.display = 'none';
}
} else {
// Main page specific code
const newElement = document.createElement('div');
newElement.className = "align-middle";
newElement.innerHTML = `
<div class="quarto-title-meta">
<div class="quarto-title-meta-column-start">
<div class="manuscript-info">
<div class="flex-none pr-2 smallcaps">Manuscript</div>
<div class="flex-none mr-2 pl-2 smallcaps">
<span class="font-semibold">A preprint version</span>
</div>
</div>
</div>
<div class="quarto-title-meta-column-icon">
<div class="science-info sm:block">
<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank" rel="noopener noreferrer" class="opacity-50 hover:opacity-100 text-inherit hover:text-inherit" aria-label="Content License: Creative Commons Attribution Share Alike 3.0 Unported (CC-BY-SA-3.0)">
<img class="science-icon inline-block mx-1" src="https://raw.githubusercontent.com/ntluong95/data/main/cc.svg" alt="CC BY-SA 3.0" />
<img class="science-icon inline-block mr-1" src="https://raw.githubusercontent.com/ntluong95/data/main/by.svg" alt="Credit must be given to the creator" />
<img class="science-icon inline-block mr-1" src="https://raw.githubusercontent.com/ntluong95/data/main/sa.svg" alt="Adaptations must be shared under the same terms" />
</a>
<a href="https://opensource.org/licenses/MIT" target="_blank" rel="noopener noreferrer" title="Code License: MIT License (MIT)" class="text-inherit hover:text-inherit">
<img class="science-icon mx-1 inline-block opacity-60 hover:opacity-100 hover:text-[#599F46]" src="https://raw.githubusercontent.com/ntluong95/data/main/mit.svg" alt="MIT License" />
</a>
<a href="https://en.wikipedia.org/wiki/Open_access" target="_blank" rel="noopener noreferrer" title="Open Access" class="text-inherit hover:text-inherit">
<img class="science-icon mr-1 inline-block opacity-60 hover:opacity-100 hover:text-[#E18435]" src="https://raw.githubusercontent.com/ntluong95/data/main/open-access.svg" alt="Open Access" />
</a>
<a href="https://github.com/ntluong95/INFLUX" title="GitHub Repository: ntluong95/INFLUX" target="_blank" rel="noopener noreferrer" class="text-inherit hover:text-inherit">
<img class="science-icon inline-block mr-1 opacity-60 hover:opacity-100" src="https://raw.githubusercontent.com/ntluong95/data/main/github.svg" alt="GitHub Repository" />
</a>
</div>
</div>
</div>
`;
// Find the target element (the container for the icons) and insert the new element
const targetElement = document.querySelector('.column-body');
targetElement.parentNode.insertBefore(newElement, targetElement);
const columnStart = document.querySelector('.quarto-title-meta-column-start');
const metaElement = columnStart.querySelector('.quarto-title-meta'); // Select the nested element
if (metaElement) {
columnStart.parentNode.insertBefore(metaElement, columnStart.nextSibling); // Move it outside
}
// Select the abstract and keywords sections
var abstractElement = document.querySelector(".abstract");
var keywordsElement = document.querySelector(".keywords");
// Select the introduction heading
var introductionHeading = document.querySelector(
'h2[data-anchor-id="sec-introduction"]'
);
if (abstractElement && introductionHeading) {
// Create the new structure for the abstract section
var newAbstractContainer = document.createElement("div");
var newAbstractTitle = document.createElement("h3");
newAbstractTitle.id = "abstract";
newAbstractTitle.className = "mb-3 text-base font-semibold group";
newAbstractTitle.innerHTML =
'Abstract<a class="no-underline text-inherit hover:text-inherit ml-2 select-none transition-opacity opacity-0 focus:opacity-100 group-hover:opacity-70" href="#abstract" title="Link to Abstract" aria-label="Link to Abstract">¶</a>';
var newAbstractContent = document.createElement("div");
newAbstractContent.className =
"px-6 py-1 mb-3 rounded-sm bg-slate-50 dark:bg-slate-800";
var newAbstractInnerContent = document.createElement("div");
newAbstractInnerContent.id = "soTooQ8JmG";
newAbstractInnerContent.className = "relative group/block col-body";
// Move the actual abstract content
var abstractParagraph = abstractElement.querySelector("p");
newAbstractInnerContent.appendChild(abstractParagraph);
// Append all new elements to the new abstract container
newAbstractContent.appendChild(newAbstractInnerContent);
newAbstractContainer.appendChild(newAbstractTitle);
newAbstractContainer.appendChild(newAbstractContent);
// Insert the new abstract container before the introduction heading
introductionHeading.parentNode.insertBefore(
newAbstractContainer,
introductionHeading
);
// Remove the old abstract element
abstractElement.remove();
// Move the keywords section if it exists
if (keywordsElement) {
introductionHeading.parentNode.insertBefore(
keywordsElement,
introductionHeading
);
}
}
// Redesign author display
const container = document.querySelector(".quarto-title-meta-author");
const contents = container.querySelectorAll(".quarto-title-meta-contents");
const newContainer = document.createElement("div");
newContainer.classList.add("quarto-title-meta-contents");
const popup = document.createElement("div");
popup.id = "affiliation-popup";
popup.classList.add("popup");
document.body.appendChild(popup);
let currentOpenPopup = null;
for (let i = 0; i < contents.length; i++) {
const content = contents[i];
const authorElement = content.querySelector(".author");
if (authorElement) {
newContainer.appendChild(authorElement);
const affiliationContent = document.createElement("div");
affiliationContent.classList.add("popup-content");
if (i + 1 < contents.length) {
const nextContent = contents[i + 1];
const affiliations = nextContent.querySelectorAll(".affiliation");
affiliations.forEach((affiliation) =>
affiliationContent.appendChild(affiliation.cloneNode(true))
);
i++;
}
authorElement.addEventListener("click", function (event) {
event.preventDefault();
event.stopPropagation();
if (currentOpenPopup) {
currentOpenPopup.classList.remove("active");
}
currentOpenPopup = popup;
popup.innerHTML = "";
const popupHeader = document.createElement("h3");
popupHeader.innerText = authorElement.textContent.trim();
popup.appendChild(popupHeader);
popup.appendChild(affiliationContent.cloneNode(true));
popup.style.visibility = "hidden";
popup.classList.add("active");
const rect = authorElement.getBoundingClientRect();
const popupWidth = popup.offsetWidth;
const maxLeft = window.innerWidth - popupWidth;
const popupLeft = Math.min(
Math.max(0, rect.left + rect.width / 2 - popupWidth / 2),
maxLeft
);
popup.style.left = popupLeft + "px";
popup.style.top = rect.bottom + window.scrollY + "px";
popup.style.visibility = "visible";
});
}
}
document.addEventListener("click", function (event) {
if (
currentOpenPopup &&
!currentOpenPopup.contains(event.target) &&
!event.target.closest(".quarto-title-meta-author")
) {
currentOpenPopup.classList.remove("active");
currentOpenPopup = null;
}
});
container.innerHTML = "";
container.appendChild(newContainer);
// Remove blank div inside quarto-title-banner
var titleBanner = document.querySelector(".quarto-title-banner");
if (titleBanner) {
// Select all div elements inside the quarto-title-banner
var divs = titleBanner.querySelectorAll("div");
divs.forEach(function (div) {
// Check if the div is empty
if (!div.innerHTML.trim()) {
// Remove the empty div
div.remove();
}
});
}
const metaAuthor = document.querySelector('.quarto-title-meta-author');
const metaColumnStart = metaAuthor.nextElementSibling; // Get the element right after the author section
const otherFormatsTarget = document.querySelector('.quarto-title-meta-column-end.quarto-other-formats-target');
if (metaColumnStart && otherFormatsTarget) { // Add a check for the existence of elements
// Append the 'otherFormatsTarget' element to the 'metaColumnStart' element
metaColumnStart.appendChild(otherFormatsTarget);
// Optionally, adjust the styling
otherFormatsTarget.style.display = 'inline-block';
otherFormatsTarget.style.marginLeft = '20px'; // Add some spacing
} else {
console.warn("One or more required elements were not found.");
}
}
});
</script>