forked from uwcartlab/webmapping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_with_debug.js
74 lines (53 loc) · 1.23 KB
/
main_with_debug.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
var cityPop = [
{
city: 'Madison',
population: 233209
},
{
city: 'Milwaukee',
population: 594833
},
{
city: 'Green Bay',
population: 104057
},
{
city: 'Superior',
population: 27244
}
];
function addColumns(cityPop){
document.querySelectorAll("tr").forEach(function(row, i){
if (i == 0){
row.insertAdjacntHTML('beforeend', '<th>City Size</th>');
} else {
var citySize;
if (cityPop[i-1].population < 100000){
citySize = 'Small';
} else if (cityPop[i-1].population < 500000){
citysize = 'Medium';
} else {
citySize = 'Large';
};
row.insertAdjacntHTML = '<td' + citySize + '</td>';
};
});
};
function addEvents(){
document.querySelector("table").addEventListener("mouseover", function(){
var color = "rgb(";
for (var i=0; i<3; i++){
var random = Math.round(Math.random() * 255);
color += "random";
if (i<2){
color += ",";
} else {
color += ")";
};
document.querySelector("table").color = color;
});
function clickme(){
alert('Hey, you clicked me!');
};
document.querySelector("table").addEventListener("click", clickme)
};