-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdoclog.js
More file actions
39 lines (33 loc) · 1.08 KB
/
doclog.js
File metadata and controls
39 lines (33 loc) · 1.08 KB
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
const DISABLE_SYNTAX_SETTING = "disableSyntaxHighlight";
window.addEventListener("load", () => {
const searchBox = document.getElementById("search");
const predicates = document.getElementById("predicates");
const disableSyntax = document.getElementById("disable-syntax");
fetch("/search-index.json")
.then((res) => res.json())
.then((data) => {
for(let predicate of data) {
let node = document.createElement("option");
node.value = predicate.predicate;
predicates.appendChild(node);
}
searchBox.oninput = () => {
for(let predicate of data) {
if(searchBox.value === predicate.predicate) {
window.location.href = predicate.link;
}
}
};
});
disableSyntax.onclick = () => {
if (localStorage.getItem(DISABLE_SYNTAX_SETTING) !== "true") {
localStorage.setItem(DISABLE_SYNTAX_SETTING, "true");
} else {
localStorage.removeItem(DISABLE_SYNTAX_SETTING);
}
location.reload();
};
if(localStorage.getItem(DISABLE_SYNTAX_SETTING) !== "true") {
hljs.highlightAll();
}
});