-
Notifications
You must be signed in to change notification settings - Fork 10
/
script.js
167 lines (151 loc) · 4.68 KB
/
script.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
var container = document.querySelector(".container");
var dropdownList = document.querySelector(".dropdown-list");
var dropdownBtn = document.querySelector(".dropdown-btn");
var dropdown = document.querySelector(".dropdown");
var scrollTop = document.querySelector(".scroll-top");
var viz =
[
{
"name" : "Average Temperature",
"viz" : "avg-temp/avg-temp.png"
},
{
"name" : "Crime Rate in India",
"viz" : "crime-rate/crime-rate.png"
},
{
"name" : "Equity Graph",
"viz" : "Equity-graphs/graph.jpg"
},
{
"name" : "High Jump",
"viz" : "highjump/final_plot.png"
},
{
"name" : "Hotels",
"viz" : "hotels/hotel.png"
},
{
"name" : "Sudoku Difficulty",
"viz" : "sudoku/final_lot.png"
},
{
"name" : "Net Worth of Billionaires",
"viz" : "treemaps/billionaires.png"
},
{
"name" : "Revenue from Star Wars movies",
"viz" : "treemaps/star-wars.png"
},
{
"name" : "Wonder Woman WordCloud",
"viz" : "word-clouds/1-wonder-woman.png"
},
{
"name" : "The Dark Knight WordCloud",
"viz" : "word-clouds/2-dark-knight.png"
},
{
"name" : "Civil War WordCloud",
"viz" : "word-clouds/3-civil-war.png"
},
{
"name" : "Sherlock WordCloud",
"viz" : "word-clouds/4-sherlock.png"
},
{
"name" : "Donald Trump WordCloud",
"viz" : "word-clouds/5-trump.png"
},
{
"name" : "Star Wars WordCloud",
"viz" : "word-clouds/6-star-wars.png"
},
{
"name" : "Music Downloads",
"viz" : "music-downloads/Python/final_plot.png"
},
{
"name" : "Faculty Training Budget in IITs",
"viz" : "IIT_Faculty_training_Budget/data.png"
},
{
"name" : "OpenCode18",
"viz" : "opencode/plot.png"
}
];
for(var i = 0; i < viz.length; i++)
{
var div1 = document.createElement("div");
var div2 = document.createElement("div");
var li1 = document.createElement("li");
div1.classList.add("viz");
li1.classList.add("dropdown-list");
var image = document.createElement("img");
image.setAttribute("src", viz[i].viz);
image.setAttribute("width", "150%");
var hr = document.createElement("hr");
var h1 = document.createElement("h1");
var t = document.createTextNode(viz[i].name);
var t2 = document.createTextNode(viz[i].name);
h1.appendChild(t);
li1.appendChild(t2);
dropdownList.appendChild(li1);
div1.appendChild(h1);
div1.appendChild(image);
div2.appendChild(hr);
container.appendChild(div1);
container.appendChild(div2);
}
var vizClass = document.querySelectorAll(".viz");
for(var i = 0; i < viz.length; i++)
{
vizClass[i].addEventListener("click", function()
{
dropdown.classList.add("dropdown-visible");
});
}
var dropdownLi = document.querySelectorAll(".dropdown-list li");
var divs = document.querySelectorAll(".container div.viz");
dropdownBtn.addEventListener("click", function()
{
dropdown.classList.toggle("dropdown-visible");
});
for(var j = 0; j < dropdownLi.length; j++)
{
dropdownLi[j].addEventListener("click", function()
{
for(var k = 0; k < dropdownLi.length; k++)
{
if(this == dropdownLi[k])
{
window.scroll({ top: divs[k].offsetTop, left: 0, behavior: "smooth" });
}
}
dropdown.classList.add("dropdown-visible");
});
}
scrollTop.addEventListener("click", function()
{
window.scroll({ top: 0, left: 0, behavior: "smooth" });
});
container.addEventListener("click", function()
{
dropdown.classList.add("dropdown-visible");
});
dropdownList.addEventListener("click", function()
{
dropdown.classList.add("dropdown-visible");
});
window.onscroll = function() {scrollUp()};
function scrollUp()
{
if (document.body.scrollTop > 260 || document.documentElement.scrollTop > 260)
{
scrollTop.style.display = "block";
}
else
{
scrollTop.style.display = "none";
}
}