-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlexicon.js
32 lines (29 loc) · 1.01 KB
/
lexicon.js
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
fetch("../lexicon.json").then(r => r.json())
.then(lexicon => {
const alreadyDone = {};
[...document.querySelectorAll("a.dfn")].forEach(a => {
if (lexicon[a.textContent] && !alreadyDone[a.textContent]) {
let target = lexicon[a.textContent];
if (target.alias) {
target = lexicon[target.alias];
}
if (target.href) {
a.href = target.href;
return;
}
const dfnId = target.toLowerCase().replace(/[^a-z0-9]/g, '');
const dfn = document.createElement("p");
dfn.id = dfnId;
dfn.className = "hidden";
dfn.innerHTML = target;
document.getElementById("lexicon").appendChild(dfn);
a.className = "js-simple-tooltip";
a.dataset.simpletooltipContentId = dfnId;
alreadyDone[a.textContent] = true;
} else {
a.replaceWith(a.textContent);
}
});
const my_tooltip = van11yAccessibleSimpleTooltipAria();
my_tooltip.attach(document.getElementById('slides'));
});