generated from ait-tr/cohort-xx.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lesson.html
155 lines (146 loc) · 8.74 KB
/
lesson.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.1.0/github-markdown.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
<script src="prism.js"></script>
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
.accordion-item.plan, .accordion-item.theory, .accordion-item.code, .accordion-item.homework {
display: none;
}
/* PrismJS 1.29.0 https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript */
code[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}
</style>
</head>
<body>
<div class="accordion">
<div class="accordion-item plan">
<h2 class="accordion-header" id="accordion-header-plan">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
Plan
</button>
</h2>
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show" aria-labelledby="accordion-header-plan">
<div class="accordion-body">
<div id="plan"></div>
</div>
</div>
</div>
<div class="accordion-item theory">
<h2 class="accordion-header" id="panelsStayOpen-headingTwo">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="true" aria-controls="panelsStayOpen-collapseTwo">
Theory
</button>
</h2>
<div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse" aria-labelledby="panelsStayOpen-headingTwo">
<div class="accordion-body">
<div id="theory"></div>
</div>
</div>
</div>
<div class="accordion-item homework">
<h2 class="accordion-header" id="panelsStayOpen-headingThree">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseThree" aria-expanded="true" aria-controls="panelsStayOpen-collapseThree">
Homework
</button>
</h2>
<div id="panelsStayOpen-collapseThree" class="accordion-collapse collapse" aria-labelledby="panelsStayOpen-headingThree">
<div class="accordion-body">
<div id="homework"></div>
</div>
</div>
</div>
<div class="accordion-item presentation">
<h2 class="accordion-header" id="presentation-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#presentation-body" aria-expanded="true" aria-controls="presentation-body">
Homework
</button>
</h2>
<div id="presentation-body" class="accordion-collapse collapse" aria-labelledby="presentation-header">
<div class="accordion-body">
<div id="presentation"></div>
</div>
</div>
</div>
<div class="accordion-item code">
<h2 class="accordion-header" id="accordion-header-code">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#accordion-body-code" aria-expanded="true" aria-controls="panelsStayOpen-collapseThree">
Code
</button>
</h2>
<div id="accordion-body-code" class="accordion-collapse collapse" aria-labelledby="accordion-header-code">
<div class="accordion-body">
<div id="code"></div>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
const queryDict = {};
location.search.substr(1).split("&").forEach(
function(item) {queryDict[item.split("=")[0]] = item.split("=")[1]}
);
const converter = new showdown.Converter();
let baseUrl;
fetch(queryDict.file)
.then(response => {
baseUrl = response.url.split("metadata.json")[0];
return response.json();
})
.then(metadata => {
if (metadata.plan) {
document.querySelector('.accordion-item.plan').style.display = 'block';
displayMdFile(baseUrl + metadata.plan, document.getElementById('plan'));
}
if (metadata.theory) {
document.querySelector('.accordion-item.theory').style.display = 'block';
displayMdFile(baseUrl + metadata.theory, document.getElementById('theory'));
}
if (metadata.homework) {
document.querySelector('.accordion-item.homework').style.display = 'block';
displayMdFile(baseUrl + metadata.homework, document.getElementById('homework'));
}
if (metadata.code) {
document.querySelector('.accordion-item.code').style.display = 'block';
const codeElement = document.getElementById('code');
metadata.code.forEach(codeFile => {
const fileName = document.createElement('div');
fileName.innerHTML = codeFile;
const codeItem = document.createElement('div');
codeElement.appendChild(fileName);
codeElement.appendChild(codeItem);
displayMdFile(baseUrl + codeFile, codeItem, "java");
})
}
})
function displayMdFile(path, element, code) {
console.log(path, element);
fetch(path)
.then((response) => response.text())
.then((text) => {
console.log(text);
element.innerHTML = converter.makeHtml(code? "```" + code + "\n" + text + "\n```" : text);
Prism.highlightAllUnder(element);
});
}
</script>