This repository has been archived by the owner on Oct 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanual.html
85 lines (77 loc) · 2.55 KB
/
manual.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
---
title: Manual
layout: internal
---
<div class="container-fluid background-manual">
<div class="container">
<div class="row">
<div class="col-lg-4 col-12 pt-3 pb-5">
<div class="sticky-top pt-5">
<div id="toc-container">
<h3 id="toc-title">User Manual</h3>
<ol id="toc" class="list-group"></ol>
</div>
</div>
</div>
<div
class="col-lg-8 col-12 background-white py-3 pl-lg-5 pl-3 md-content"
>
<div id="md-manual" class="pt-5">
{% capture markdown %}{% include_relative content.md %}{% endcapture
%} {{ markdown | markdownify }}
</div>
</div>
</div>
</div>
</div>
<script>
function elem(tag, elems, attrs) {
var parent = document.createElement(tag);
if (attrs) Object.entries(attrs).forEach((kv) => (parent[kv[0]] = kv[1]));
if (elems) elems.forEach((x) => parent.appendChild(x));
return parent;
}
function queryAll(s) {
return Array.prototype.slice.call(document.querySelectorAll(s));
}
function query(s) {
return document.querySelector(s);
}
// wait for HTML to finish loading, as we need document.body
window.onload = function () {
var toc = query("#toc");
if (toc) {
var currentList = toc;
var currentDepth = 1;
var numbering = [0, 0, 0, 0, 0];
var headlines = queryAll(
"#md-manual>h1, #md-manual>h2, #md-manual>h3, #md-manual>h4, #md-manual>h5, #md-manual>h6"
);
headlines.forEach((headline, i) => {
var depth = parseInt(headline.nodeName[1]); // 1, 2, 3, 4
++numbering[depth];
numbering.forEach((_, i) => (i > depth ? (numbering[i] = 0) : 0));
var chapter = numbering.slice(1, depth + 1).join(".") + ". ";
headline.textContent = chapter + headline.textContent;
for (; currentDepth < depth; currentDepth++)
currentList = currentList.lastChild.lastChild;
for (; currentDepth > depth; currentDepth--)
currentList = currentList.parentNode.parentNode;
var link = elem("a", [], {
textContent: headline.textContent,
href: "#" + headline.id,
});
var div = elem("div", [link]);
var hasSubsections =
headlines[i + 1] && parseInt(headlines[i + 1].nodeName[1]) > depth;
if (!hasSubsections) currentList.appendChild(div);
else
currentList.appendChild(
elem("details", [elem("summary", [div]), elem("div")], {
open: false,
})
);
});
}
};
</script>