-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdatamenu.js
98 lines (84 loc) · 2.29 KB
/
datamenu.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* datamenu.js
* Gives the user options to load data
*
* Author: Yang Chaoyu, Aniket Handa, Gregory Nelson, A Conrad Nied
*
* 2014-03-20
*/
// Get the current page hash
hash = location.hash;
if(hash == null || hash == "") {
hash = '95-LD';
location.hash = hash;
}
// Get constituents
perc = hash.substring(1, 3);
cond = hash.substring(4, 6);
// Load the page's data
//loaddata();
// Options
conditions = ["HD", "LD", "HF", "LF", "NU"];
percentiles = ["99", "95", "50"];
condition_labels = {"HD": "High Lexical Density",
"LD": "Low Lexical Density",
"HF": "High Phonological Frequency",
"LF": "Low Phonological Frequency",
"NU": "Random Data (Null Hypothesis)"};
// Set the datamenu
var datamenu_area = d3.select('#datamenu')
.attr('width', 750)
.attr('height', 20)
.style("display","block")
.style("margin","auto")
.style("text-align","center")
.style("width","750px");
// Modify Condition
datamenu_area.append("span")
.text('Neural processing while hearing words.');
datamenu_area.append("span")
.text('Group:')
.style('padding', '0px 5px 0px 10px');
datamenu_area.append("select")
.attr('id', 'condition_selector')
.style("width","240px")
.attr("value", "7")
.selectAll("option")
.data(conditions)
.enter()
.append("option")
.text(function(d) {return condition_labels[d];})
.attr("id", function(d) {return "cond" + d;});
d3.select("#cond" + cond)
.attr("selected", "");
d3.select("#condition_selector")
.attr('selectedIndex', 2)
.on("change", function() {
cond = conditions[this.selectedIndex];
location.hash = perc + "-" + cond;
// location.reload();
loaddata();
});
// Modify percentile
datamenu_area.append("span")
.text('GCI Percentile:')
.style('padding', '0px 5px 0px 15px');
datamenu_area.append("select")
.attr('id', 'threshold_selector')
.style("width","75px")
.attr("value", "7")
.selectAll("option")
.data(percentiles)
.enter()
.append("option")
.text(function(d) {return d + "th";})
.attr("id", function(d) {return "thresh" + d;});
d3.select("#thresh" + perc)
.attr("selected", "");
d3.select("#threshold_selector")
.attr('selectedIndex', 2)
.on("change", function() {
perc = percentiles[this.selectedIndex];
location.hash = perc + "-" + cond;
// location.reload();
loaddata();
});