-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
257 lines (207 loc) · 4.98 KB
/
index.html
File metadata and controls
257 lines (207 loc) · 4.98 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Documentation | Oomph</title>
<link rel="preconnect stylesheet" href="project.css" />
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked-gfm-heading-id/lib/index.umd.js"></script>
<script src="project.js"></script>
<style>
/* <![CDATA[*/
img {
max-width: 100%;
}
th,
td {
border: 1px solid black;
padding: 0.2ex 1em;
}
th {
text-align: center;
}
td {
text-align: left;
}
table {
border: 1px solid black;
border-collapse: collapse;
margin-bottom: 2ex;
}
#table-of-contents {
padding: 0;
margin: 0;
margin-left: 0.5em;
}
.tl1 {
margin-left: 0em;
font-size: 90%;
}
.tl2 {
margin-left: 0.5em;
font-size: 85%;
}
.tl3 {
margin-left: 1.0em;
font-size: 80%;
}
.tl4 {
margin-left: 1.5em;
font-size: 75%;
}
.tl5 {
margin-left: 2.0em;
font-size: 75%;
}
.tl6 {
margin-left: 2.5em;
font-size: 75%;
}
#toc {
float: right;
position: sticky;
top: 0;
margin-top: 1.5em;
}
#toc .sideitem {
padding: 0.5em 0.5em;
margin-bottom: 0;
}
#toc h2 {
margin-bottom: 0.5em;
padding-bottom: 0.0em;
}
#toc #table-of-contents {
max-height: 66vh;
overflow-y: auto;
}
details>summary {
margin-bottom: 0.5em;
}
details>summary::before {
content: '▷️ ';
color: orange;
}
details[open]>summary::before {
content: '◢ ';
color: orange;
}
:target {
border-style: solid;
border-width: 1px;
}
#edit-markdown-link {
display: block;
margin-bottom: 1em;
}
/*]]>*/
</style>
</head>
<body>
<div data-generate="generateDefaultBreadcrumb(this)">
<a href=".">Oomph</a>
</div>
<div data-generate="generateDefaults(this)">
</div>
<main>
<div id="markdown-target"></div>
</main>
<script>
//<![CDATA[
function getFileParameter() {
const search = new URLSearchParams(window.location.search);
return search.get('file') ?? 'index.md';
}
const file = getFileParameter();
tableOfContentsAside = `
<div id="toc" class="col-md-6">
<aside>
<ul class="ul-left-nav">
<div class="sideitem">
<h2>Table of Contents</h2>
<div id="toc-target">
</div>
</div>
</ul>
</aside>
</div>`;
generate();
const targetElement = document.getElementById('markdown-target');
function fixHash(hash) {
return hash.toLowerCase();
}
function generateMarkdown(response) {
const text = response;
const editLink = `<a id="edit-markdown-link" href=""><span class="orange">\u270E Improve this page</span></a>\n`;
marked.use(markedGfmHeadingId.gfmHeadingId());
marked.use({
hooks: {
postprocess(html) {
return `${html}`;
}
}
});
targetElement.innerHTML = editLink + marked.parse(text);
const headings = markedGfmHeadingId.getHeadingList();
const headingText = `
<ul id="table-of-contents">
${headings.map(({id, raw, level}) => `<li class="tl${level}"><a href="#${id}">${raw}</a></li>`).join(' ')}
</ul>
`;
document.getElementById('toc-target').replaceChildren(...toElements(headingText));
const as = targetElement.querySelectorAll("a[href]");
for (const a of as) {
const href = a.getAttribute('href');
if (href == null || href == '') {
continue;
}
if (href.startsWith('#')) {
a.setAttribute('href', fixHash(href));
continue;
}
if (!href.startsWith('http') && !href.startsWith('/') && !href.startsWith('mailto:')) {
const url = new URL(window.location);
url.search = '';
url.hash = '';
a.href = `${url.href}?file=${href}`;
}
}
document.getElementById('edit-markdown-link').href = `https://github.com/eclipse-oomph/oomph-website/blob/master/${file}`;
// Ensure that we nagivate to the target.
if (document.location.hash.includes('#')) {
document.location.hash = document.location.hash;
}
updateTocSize();
}
document.title = `Oomph | ${niceName(file.replace(/^.*\//, ''))}`;
const localURL = new URL(file, window.location);
defaultURL = localURL.toString();
function defaultHandler(url) {
fetch(url).then(response => {
return response.text();
}).then(text => {
generateMarkdown(text);
});
}
defaultHandler(defaultURL);
function updateTocSize() {
const toc = document.getElementById('toc');
const tocInner = document.getElementById('table-of-contents');
if (toc != null && tocInner != null) {
const height = window.document.documentElement.clientHeight;
tocInner.style.maxHeight = `${height - tocInner.getBoundingClientRect().top - 20}px`;
toc.style.maxHeight = `${height - toc.getBoundingClientRect().top - 20}px`;
}
}
const onscroll = window.onscroll;
window.onscroll = function (event) {
if (onscroll != null) {
onscroll(event);
}
updateTocSize();
};
window.onresize = updateTocSize;
//]]>
</script>
</body>