-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
141 lines (127 loc) · 3.53 KB
/
index.html
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
<!DOCTYPE html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>CountryCO2</title>
<link rel="canonical" href=".">
<!-- <link rel="stylesheet" href=".style.css"> -->
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<style>
* {
box-sizing: border-box;
}
.sidenav {
height: 100%;
width: 250px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: black;
overflow-x: hidden;
padding-top: 20px;
font-family: monospace;
color: white;
}
.sidenav a {
padding: 10px 8px 10px 20px;
text-decoration: none;
font-size: 20px;
color: white;
display: block;
}
.sidenav a:hover {
background-color:#595959;
}
form {
margin: 2rem auto 0;
}
#inputForm{
padding-left: 250px;
}
#inputForm input {
display: block;
display: inline-block;
font-size: 16px;
line-height: 2.0;
text-overflow: ellipsis;
width: 40%;
border-radius: 5px;
}
#inputForm input[type="button" i]{
font-size: 16px;
width: 10%;
color: white;
padding: 3px;
background-color: black;
border: none;
font-family:monospace;
}
</style>
</head>
<body>
<div class="sidenav">
<p style="padding-left: 20px; font-size: 25px">Footprint >> </p>
<br></br>
<a href="/">Map Veiw</a>
<a href="/circle">How Big Is Your Pie?</a>
<a href="/rectangleVeiw">Global Emissions In A Box</a>
</div>
<center>
<br></br>
<form id="inputForm">
<input type="text" name="countryInput" placeholder="Country">
<input type="button" onclick="getResultingCountries()" value="Submit">
</form>
<br></br>
</center>
<script>
var globalData = "";
async function getResultingCountries() {
var valsInForm = document.getElementById("inputForm");
var input = valsInForm.elements[0].value;
await fetch(window.location.href + 'query?country=' + input)
.then((response) => {
return response.json().then((data) => {
globalData = data;
return data;
}).catch((err) => {
console.log(err);
})
});
console.log(globalData);
document.getElementById("percentOfTot").innerHTML = globalData.pOfTot + " & " + globalData.length + " Countries";
google.charts.load('current', {
'packages':['geochart'],
'mapsApiKey': 'AIzaSyD-9tSrke72PouQMnMX-a7eZSW0jkFMBWY'
});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = new google.visualization.DataTable();
data.addRows(globalData.items.length + 1)
data.addColumn('string', 'Country');
data.addColumn('number', 'Emissions');
for(var i = 0; i < globalData.items.length; i++){
data.setValue(i, 0, globalData.items[i].name);
data.setValue(i, 1, globalData.items[i].emissions);
}
data.setValue(globalData.items.length, 0, globalData.input[0].name);
data.setValue(globalData.items.length, 1, null);
var options = {
backgroundColor: {
fill: '#b0d3f5',
},
defaultColor: 'red',
};
var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));
chart.draw(data, options);
}
}
</script>
</body>
<center>
<p id="percentOfTot" style = "padding-left: 250px; font-family: monospace; font-size:20px "></p>
<div id="regions_div" style="width: 90%; height: 600px; padding-left: 250px"></div>
</center>
</html>