-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubject-knowledge-2021.html
More file actions
executable file
·151 lines (119 loc) · 4.45 KB
/
subject-knowledge-2021.html
File metadata and controls
executable file
·151 lines (119 loc) · 4.45 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
<!DOCTYPE html><html>
<head>
<meta charset="utf-8" />
<link id="favicon" rel="shortcut icon" type="image/png" href="data:image/png;base64,....==" />
<title>Subject Knowledge Audit</title>
<link rel="stylesheet" href="_base.css">
<style>
td .title {
font-weight: bold;
}
td .description {
color: grey;
font-size: smaller;
}
th:nth-child(n+4) {
writing-mode: vertical-lr;
padding: 1em;
}
</style>
<script src="https://unpkg.com/showdown/dist/showdown.min.js"></script>
</head>
<body>
<div id="navigation"></div>
<div id="description"></div>
<div class="page_break"></div>
<h1>Subject Knowledge Tracker</h1>
<div id="main"></div>
<div class="page_break"></div>
<div id="additional"></div>
<script type="module">
//const QUERY_STRING_project = 'project';
//const urlParams = new URLSearchParams(window.location.search);
const navigationElement = document.getElementById('navigation');
const mainElement = document.getElementById('main') || document.getElementsByTagName('body').item(0);
// Markdown --------------------------------------------------------------------
function renderMarkdownFileToElement(url, $el) {
fetch(url)
.then(response => response.text())
.then((markdown_data) => {
const converter = new showdown.Converter(); // https://github.com/showdownjs/showdown
$el.innerHTML = converter.makeHtml(markdown_data);
})
.catch(err => console.error(err));
}
renderMarkdownFileToElement(`subject_knowledge-2021.md`, document.getElementById("description"));
renderMarkdownFileToElement(`level_descriptors.md`, document.getElementById("additional"));
// Main ------------------------------------------------------------------------
let _data;
window.onhashchange = function() {
renderData(_data);
}
function renderData(data) {
// Clear existing html
navigationElement.innerHTML = '';
mainElement.innerHTML = '';
let tags = data.reduce(
(acc, item) => {
for (let tag of item.tags) {acc.add(tag);}
return acc;
},
new Set(),
);
console.log(tags);
let keys = ["", "", "Tags", "Pre-course", "December", "April", "June"]
// Build Table
const table = document.createElement('table');
// Table - Heading
const table_headings = document.createElement('thead');
//table_headings.appendChild(document.createElement('th'));
for (let key of keys) {
const table_heading = document.createElement('th');
table_heading.textContent = key;
table_headings.appendChild(table_heading);
}
table.appendChild(table_headings);
// Table - Rows
let item_count = 0;
for (let item of data) {
const table_row = document.createElement('tr');
const el_count = document.createElement('td');
el_count.textContent = ++item_count;
table_row.appendChild(el_count);
// Item
const table_item = document.createElement('td');
const el_title = document.createElement('p');
const el_description = document.createElement('p');
el_title.className = "title";
el_description.className = "description";
table_item.appendChild(el_title);
table_item.appendChild(el_description);
el_title.textContent = item.title;
el_description.textContent = item.description;
//table_row_name.textContent = `<>`
//table_item.innerHTML = `<p>${}</p><p>${item['description']}</p>`;
table_row.appendChild(table_item);
const el_tags = document.createElement('td');
const el_tags_list = document.createElement('ul');
for (let tag of item.tags) {
const _li = document.createElement('li');
_li.textContent = tag;
_li.className = `tag_${tag}`;
el_tags_list.appendChild(_li);
}
el_tags.appendChild(el_tags_list);
table_row.appendChild(el_tags);
// Create empty cells - not happy about how clumbsy this is
for (let i=0 ; i < 4 ; i++) {
table_row.appendChild(document.createElement('td'));
}
table.appendChild(table_row);
}
mainElement.appendChild(table);
}
fetch(`subject-knowledge-2021.json`)
.then(response => response.json())
.then((data)=>_data=data)
.then(renderData)
.catch(err => console.error(err));
</script></body></html>