MCPcopy Index your code
hub / github.com/GoogleTrends/data / initFilters

Function initFilters

tableload.js:45–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43 }
44
45 function initFilters() {
46 var subjects = {}, coverage = {};
47 var minYear, maxYear;
48 var minDate = new Date(), maxDate = new Date(0);
49 var i;
50 var myOption;
51
52 data.forEach(function(d) {
53 d.subject.split(",").forEach(function(item) {
54 subjects[item.trim()] = true;
55 });
56
57 d.coverage.split(",").forEach(function(item) {
58 coverage[item.trim()] = true;
59 });
60
61 if (minDate > d.date) {minDate = d.date;}
62 if (maxDate < d.date) {maxDate = d.date;}
63 })
64 minYear = minDate.getUTCFullYear();
65 maxYear = maxDate.getUTCFullYear();
66 subjects = ["all"].concat(Object.keys(subjects).sort());
67 coverage = ["all"].concat(Object.keys(coverage).sort());
68
69 fromPicker = new Pikaday({
70 field: fromFilter,
71 position: 'top left',
72 firstDay: 1,
73 minDate: minDate,
74 maxDate: maxDate,
75 yearRange: [minYear, maxYear]
76 });
77
78 toPicker = new Pikaday({
79 field: toFilter,
80 position: 'top left',
81 firstDay: 1,
82 minDate: minDate,
83 maxDate: maxDate,
84 yearRange: [minYear, maxYear]
85 });
86
87 while (subjectFilter.firstChild) {
88 subjectFilter.remove(subjectFilter.firstChild);
89 }
90 while (coverageFilter.firstChild) {
91 coverageFilter.remove(coverageFilter.firstChild);
92 }
93 subjects.forEach(function(d, i) {
94 myOption = document.createElement("option");
95 myOption.value = d;
96 myOption.innerHTML = d;
97 subjectFilter.appendChild(myOption);
98 })
99
100 coverage.forEach(function(d, i) {
101 myOption = document.createElement("option");
102 myOption.value = d;

Callers 1

loadDataFunction · 0.85

Calls 2

filterDataFunction · 0.85
showDataFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…