-
Notifications
You must be signed in to change notification settings - Fork 8
/
periodictablepage.js
84 lines (63 loc) · 2.2 KB
/
periodictablepage.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
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
const APP = {};
window.onload = function()
{
SetEventHandlers();
APP.periodictable = new PeriodicTable();
APP.display = new PeriodicTableDisplay(APP.periodictable, "periodictable", "infoboxbackground", "infobox");
APP.filterinputs =
{
name: document.getElementById("namefilter"),
atomicnumber: document.getElementById("atomicnumberfilter"),
symbol: document.getElementById("symbolfilter"),
category: document.getElementById("categoryfilter"),
group: document.getElementById("groupfilter"),
period: document.getElementById("periodfilter"),
block: document.getElementById("blockfilter")
};
}
function SetEventHandlers()
{
document.getElementById("btnApplyFilter").onclick = ApplyFilter;
document.getElementById("btnClearFilter").onclick = ClearFilter;
document.getElementById("colorblock").onclick = ColorByBlock;
document.getElementById("colorcategory").onclick = ColorByCategory;
}
function ColorByBlock()
{
this.blur();
document.getElementById("categorykey").style.display = "none";
document.getElementById("blockkey").style.display = "inline";
APP.display.ColorByBlock();
}
function ColorByCategory()
{
this.blur();
document.getElementById("blockkey").style.display = "none";
document.getElementById("categorykey").style.display = "inline";
APP.display.ColorByCategory();
}
function ApplyFilter()
{
filtercriteria =
{
name: APP.filterinputs.name.value,
atomicnumber: APP.filterinputs.atomicnumber.value,
symbol: APP.filterinputs.symbol.value,
category: APP.filterinputs.category.value,
group: APP.filterinputs.group.value,
period: APP.filterinputs.period.value,
block: APP.filterinputs.block.value
};
APP.periodictable.ApplyFilter(filtercriteria)
}
function ClearFilter()
{
APP.filterinputs.name.value = "";
APP.filterinputs.atomicnumber.value = "";
APP.filterinputs.symbol.value = "";
APP.filterinputs.category.value = "";
APP.filterinputs.group.value = "";
APP.filterinputs.period.value = "";
APP.filterinputs.block.value = "";
APP.periodictable.ClearFilter();
}