-
Notifications
You must be signed in to change notification settings - Fork 0
/
school_filter.js
37 lines (34 loc) · 959 Bytes
/
school_filter.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
function init()
{
function get_school(row)
{
const school_column = 1;
return row.cells[school_column].innerText;
}
var table = document.getElementById("results")
var schools = new Set();
for (var i=1, row; row=table.rows[i]; i++)
{
schools.add(get_school(row));
}
schools = Array.from(schools);
schools.sort();
var school_select = document.getElementById("cb-school");
for (var i in schools)
{
var option = document.createElement('option');
option.text = option.value = schools[i];
school_select.add(option);
}
school_select.onchange = function()
{
var school = school_select.value;
var show_all = school == "all";
for (var i=1, row; row=table.rows[i]; i++)
{
var match = get_school(row) == school;
row.style.display = (match || show_all) ? "" : "None";
}
}
}
init();