forked from EmilHvitfeldt/feature-engineering-az
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.html
More file actions
55 lines (51 loc) · 1.83 KB
/
misc.html
File metadata and controls
55 lines (51 loc) · 1.83 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!-- collapse buttons -->
<script>
// Collapse button
var container = document.querySelector(".sidebar-title");
var button = document.createElement("button");
button.style.border = "none";
button.style.backgroundColor = "unset";
var icon_collapse = document.createElement("i");
icon_collapse.classList = "bi bi-arrows-collapse";
button.appendChild(icon_collapse);
button.onclick = onbuttonclicked;
container.appendChild(button);
function onbuttonclicked() {
if (icon_collapse.classList == "bi bi-arrows-collapse") {
document.querySelectorAll(
"a.sidebar-item-toggle:not(.collapsed)"
).forEach((x) => x.click());
icon_collapse.classList = "bi bi-arrows-expand";
} else {
document.querySelectorAll(
"a.sidebar-item-toggle.collapsed"
).forEach((x) => x.click());
icon_collapse.classList = "bi bi-arrows-collapse";
}
}
// random button
var container = document.querySelector(".sidebar-title");
var button = document.createElement("button");
button.style.border = "none";
button.style.backgroundColor = "unset";
var icon_random = document.createElement("i");
icon_random.classList = "bi bi-dice-6";
button.appendChild(icon_random);
button.onclick = onbuttonclicked_random;
container.appendChild(button);
function onbuttonclicked_random() {
// All sidebar links
links = document.querySelectorAll(".sidebar-item-text.sidebar-link");
// Only keep chapters
links = Array.from(links).filter(element =>
element.querySelector(".chapter-number")
);
// Remove WIP chapters
links = links.filter(element => {
const span = element.querySelector("span.chapter-title");
return !(span && span.textContent.includes("🏗️"));
});
const link = links[Math.floor(Math.random() * links.length)];
link.click();
}
</script>