-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
279 lines (268 loc) · 11.4 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<title>MUN Research</title>
</head>
<body>
<header id="header" class="bg-dark" style="margin: 0 0 25px 0">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark container">
<ul class="navbar-nav mr-auto">
<li>
<h1>MUN Research</h1>
</li>
</ul>
</nav>
</header>
<form class="form-inline my-2 my-lg-0" action="/search" method="post" style="margin: 25px 0 0 25px">
<label for="promptagenda" style="margin: 0 10px 0 0">Enter your agenda:</label><br>
<input class="form-control mr-sm-2" aria-label="Enter your agenda" type="text" id="promptagenda" name="promptagenda"><br>
<label for="promptcountry" style="margin: 0 10px 0 0">Enter your country:</label><br>
<input class="form-control mr-sm-2" aria-label="Enter your Country" type="text" id="promptcountry" name="promptcountry"><br>
<input class="btn btn-outline-success my-2 my-sm-0" type="submit" value="Submit">
</form>
<h3 style="margin: 25px 0 5px 25px">Country Information</h3>
<div>
<div style="margin: 0 25px 0 25px">
<table class="table">
<thead>
<tr>
<th>Capital</th>
<th>Region</th>
<th>Economic Status</th>
<th>Flag</th>
</tr>
</thead>
<tbody>
<tr>
<td id="capital"></td>
<td id="region"></td>
<td id="econstatus"></td>
<td id="flag"></td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 style="margin: 25px 0 5px 25px">Recent News on the Agenda (from Reuters)</h3>
<div>
<div style="margin: 0 25px 0 25px">
<div class="table_wrapper">
<table class="table">
<thead>
<tr>
<th>Article 1</th>
<th>Article 2</th>
<th>Article 3</th>
<th>Article 4</th>
<th>Article 5</th>
<th>Article 6</th>
</tr>
</thead>
<tbody>
<tr>
<td id="article1"></td>
<td id="article2"></td>
<td id="article3"></td>
<td id="article4"></td>
<td id="article5"></td>
<td id="article6"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<h3 style="margin: 25px 0 5px 25px">Research Papers (from core.ac.uk)</h3>
<div>
<div style="margin: 0 25px 0 25px">
<div class="table_wrapper">
<table class="table">
<thead>
<tr>
<th>Paper 1</th>
<th>Paper 2</th>
<th>Paper 3</th>
<th>Paper 4</th>
<th>Paper 5</th>
<th>Paper 6</th>
</tr>
</thead>
<tbody>
<tr>
<td id="result1"></td>
<td id="result2"></td>
<td id="result3"></td>
<td id="result4"></td>
<td id="result5"></td>
<td id="result6"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<h3 style="margin: 25px 0 5px 25px">UN Documents and Articles</h3>
<div>
<div style="margin: 0 25px 0 25px">
<div class="table_wrapper">
<table class="table">
<thead>
<tr>
<th>Article 1</th>
<th>Article 2</th>
<th>Article 3</th>
<th>Article 4</th>
<th>Article 5</th>
<th>Article 6</th>
</tr>
</thead>
<tbody>
<tr>
<td id="doc1"></td>
<td id="doc2"></td>
<td id="doc3"></td>
<td id="doc4"></td>
<td id="doc5"></td>
<td id="doc6"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div style="height: 100px; margin-bottom: 50px;"></div>
<footer id="footer" class="bg-dark py-3">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark container">
<ul class="navbar-nav mr-auto">
<li class="nav-link">Made by <a href="https://github.com/AshutoshSundresh">Ashutosh Sundresh</a></li>
</ul>
<span class="navbar-text text-light">Made in 2022</span>
</nav>
</footer>
<script>
const search = async () => {
// Get the search prompt from the form
const promptagenda = document.getElementById("promptagenda").value;
const promptcountry = document.getElementById("promptcountry").value;
// Using the Google Search API to get search results, this key fetches results from core uk
const scholarUrl = `https://www.googleapis.com/customsearch/v1/siterestrict?key=AIzaSyD_2AzYp5WRBLkVxoAdPV8r9XBxrtsOe5w&cx=146c71ac6b2fe4aa7&q=${promptagenda}`;
const scholarResponse = await fetch(scholarUrl);
const scholarData = await scholarResponse.json();
// Update the table with the search results
const scholarResults = scholarData.items.slice(0, 6);
scholarResults.forEach((result, index) => {
document.getElementById(`result${index + 1}`).innerHTML = `<a href="${result.link}">"${result.title}"</a>`;
});
// Using the Google Search API to get search results, this key fetches results from reuters
const newsUrl = `https://www.googleapis.com/customsearch/v1/siterestrict?key=AIzaSyD_2AzYp5WRBLkVxoAdPV8r9XBxrtsOe5w&cx=134ca9e2191f14998&q=${promptagenda}`;
const newsResponse = await fetch(newsUrl);
const newsData = await newsResponse.json();
// Update the table with the search results
const newsResults = newsData.items.slice(0, 6);
newsResults.forEach((result, index) => {
document.getElementById(`article${index + 1}`).innerHTML = `<a href="${result.link}">"${result.title}"</a>`;
});
// Using the Google Search API to get search results, this key fetches results from UN
const unUrl = `https://www.googleapis.com/customsearch/v1/siterestrict?key=AIzaSyD_2AzYp5WRBLkVxoAdPV8r9XBxrtsOe5w&cx=1207602fe7ed442a4&q=${promptagenda}`;
const unResponse = await fetch(unUrl);
const unData = await unResponse.json();
// Update the table with the search results
const unResults = unData.items.slice(0, 6);
unResults.forEach((result, index) => {
document.getElementById(`doc${index + 1}`).innerHTML = `<a href="${result.link}">"${result.title}"</a>`;
});
// Fetch country list from datahub.io
const countryList = await fetch('https://raw.githubusercontent.com/munresearch/munresearch.github.io/master/countrylist.json');
const dataiso = await countryList.json();
// Create a map of country names to ISO 2-letter codes
const isoCodeMap = new Map();
dataiso.forEach((item) => isoCodeMap.set(item.Name, item.Code));
// Get the ISO 2-letter code for the given country
const isoCode = isoCodeMap.get(toTitleCase(promptcountry));
if (isoCode) {
// Make a GET request to the World Bank API using the ISO 2-letter code
const worldBankUrl = "https://api.worldbank.org/v2/country/" + isoCode.toLowerCase() + "?format=json";
const response = await fetch(worldBankUrl);
const data = await response.json();
// Retrieve the capital city, region, and income level from the API response
const capital = data[1][0].capitalCity;
const region = data[1][0].region.value;
const incomeLevel = data[1][0].incomeLevel.value;
const box = (ch) => String.fromCodePoint(ch.charCodeAt(0) + 0x1f1a5);
flagEmoji = box(isoCode[0]) + box(isoCode[1]);
// Update the table cells with the retrieved values
document.getElementById("capital").innerHTML = capital;
document.getElementById("region").innerHTML = region;
document.getElementById("econstatus").innerHTML = incomeLevel;
document.getElementById("flag").innerHTML = flagEmoji;
} else {
console.error("ISO code not found for given country.");
}
}
const toTitleCase = (string) => {
return string.split(" ").map((word) => word[0].toUpperCase() + word.substring(1)).join(" ");
}
// Add an event listener to the form's submit button
var form = document.querySelector("form");
form.addEventListener("submit", function(event) {
event.preventDefault();
search();
});
</script>
<style>
.table_wrapper {
display: block;
overflow-x: auto;
white-space: nowrap;
}
.content-container {
height: calc(100vh - 80px);
/* 80px is the height of the footer */
overflow: auto;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
header {
text-align: center;
/* Center the content */
color: white;
/* Set the text color */
padding: 20px;
/* Add some padding */
}
html,
body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
overflow-x: hidden;
}
header h1 {
font-size: 36px;
/* Set the font size */
font-weight: bold;
/* Make the font bold */
}
footer {
position: absolute;
bottom: 0;
height: 80px;
width: 100%;
margin-top: 20px;
margin: 0;
padding: 0;
}
@media (max-width: 768px) {
.form-control {
width: 90%;
}
}
</style>
</html>