-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.ts
32 lines (27 loc) · 914 Bytes
/
index.ts
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
type ElmPagesInit = {
load: (elmLoaded: Promise<unknown>) => Promise<void>;
flags: unknown;
};
const config: ElmPagesInit = {
load: async function (elmLoaded) {
await elmLoaded;
},
flags: function () {
return "You can decode this in Shared.elm using Json.Decode.string!";
},
};
window.addEventListener("hashchange", function(){ highlightParentOfHash(); });
window.addEventListener("load", function(){ highlightParentOfHash(); });
function highlightParentOfHash() {
let hash = window.location.hash.substr(1); // Remove the '#'
if (hash) {
let element = document.getElementById(hash);
console.log('find element', element);
if (element && element.parentElement) {
let parentElement = element.parentElement;
parentElement.classList.add("highlight");
setTimeout(() => { parentElement.classList.remove("highlight"); }, 4000);
}
}
}
export default config;