-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter_2021.js
52 lines (48 loc) · 1.26 KB
/
filter_2021.js
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
import { CSV } from "https://code4sabae.github.io/js/CSV.js";
window.onload = async () => {
const csv = await CSV.fetch("ictadvisors_2021.csv");
const csv2020 = await CSV.fetch("ictadvisors_2020.csv");
const json = CSV.toJSON(csv2020);
const search2020 = () => {
const key = inputfilter.value;
const res = [];
for (const d of json) {
let flg = false;
for (const name in d) {
if (d[name].indexOf(key) >= 0) {
flg = true;
break;
}
}
if (flg) {
const idname = d["氏名"];
res.push(idname);
}
}
return res;
};
inputfilter.onchange = inputfilter.onkeyup = () => {
const hitnames = search2020();
//console.log(hitnames);
const key = inputfilter.value;
let cnt = 0;
for (let i = 1; i < csv.length; i++) {
const d = csv[i];
const name = d[1];
let flg = hitnames.indexOf(name) >= 0;
for (const s of d) {
if (s.indexOf(key) >= 0) {
flg = true;
break;
}
}
const idname = "data" + d[0];
const div = document.getElementById(idname);
if (flg) {
cnt++;
}
div.style.display = flg ? "block" : "none";
}
filtered.textContent = `該当者:${cnt}名`;
};
};