-
Notifications
You must be signed in to change notification settings - Fork 2
/
fukui-bygrade.html
66 lines (60 loc) · 2.44 KB
/
fukui-bygrade.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
<!DOCTYPE html><html><head><meta charaset="utf-8"><meta name="viewport" content="width=device-width">
<title>福井高専カリキュラム - 高専オープンデータ</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="./style.css">
<meta name="twitter:card" content="summary_large_image">
<meta property="og:image" content="https://codeforkosen.github.io/kosen-apps/fukui.png">
<meta name="twitter:image" content="https://codeforkosen.github.io/kosen-apps/fukui.png">
</head>
<body>
<script type="module">
import { CSV } from "https://code4sabae.github.io/js/CSV.js";
import { toJA } from "./toJA.js";
window.onload = async () => {
const url = "https://codeforkosen.github.io/kosen-opendata/data/fukui/fukui-kosen-subject.csv";
const csv = await CSV.fetch(url);
const data = CSV.toJSON(csv);
console.log(data);
const p = main;
for (let i = 1; i <= 5; i++) {
const list = [];
for (const d of data) {
if (d.department === "特設科目") {
continue;
}
const n = d["grade" + i];
if (n > 0) {
const d2 = {};
Object.assign(d2, d);
d2.credit = n;
for (let j = 1; j <= 5; j++) {
delete d2["grade" + j];
}
delete d2.notes;
d2.notes = d.notes;
delete d2.kosen;
list.push(d2);
}
}
const tbl = CSV.makeTable(toJA(CSV.fromJSON(list)));
console.log(list);
const ncre = list.reduce((acc, d) => acc + parseInt(d.credit), 0);
const nsp = list.reduce((acc, d) => acc + (d.department !== "一般" ? parseInt(d.credit) : 0), 0);
const h2 = document.createElement("h2");
h2.textContent = `${i}年 ${ncre}単位 (専門${nsp}単位 ${(nsp / ncre * 100).toFixed(0)}%)`;
p.appendChild(h2);
p.appendChild(tbl);
}
};
</script>
<h1>福井高専カリキュラム</h1>
<ul id="menu">
<li><a href=fukui-all.html>電子情報工学科 科目別</a></li>
<li><a href=fukui-bygrade.html>学年別</a></li>
</ul>
<div id=main></div>
<hr>
Data: 福井高専オープンデータ(非公式) <a href=https://codeforkosen.github.io/kosen-opendata/data/fukui/fukui-kosen-subject.csv>fukui-kosen-subject.csv</a><br>
App: <a href=https://fukuno.jig.jp/3039>福野泰介の一日一創</a> (<a href=https://github.com/codeforkosen/kosen-opendata/>src on GitHub</a>)<br>
</body>
</html>