/
index.html
134 lines (120 loc) · 5.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>KosovoProject</title>
<link rel="stylesheet" href="lib/leaflet/leaflet.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://use.typekit.net/qnw7knw.css">
<link rel="stylesheet" href="https://use.typekit.net/qnw7knw.css">
</head>
<body>
<div id="map"></div>
<div class="controls">
<select id="month-select">
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
</select>
<img src="img/backward.png" id="prev-day" alt="Previous Day">
<input type="range" id="day-slider" min="1" max="31" step="1">
<img src="img/forward.png" id="next-day" alt="Next Day">
</div>
<div class="floating-query-panel">
<h2>Search:</h2>
<label for = "mon-select">Month:</label>
<select id = "mon-select">
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
</select>
<label for="region-select">Region:</label>
<select id="region-select">
<option value="Serbia">Serbia</option>
<option value="Kosovo">Kosovo</option>
<option value="Montenegro">Montenegro</option>
<option value="Belgrade">Belgrade</option>
<option value="Vojvodina">Vojvodina</option>
</select>
<label for="type-select">Type:</label>
<select id="type-select">
<option value="various">various</option>
<option value="military facility">military facility</option>
<option value="government">government</option>
<option value="infrastructure">infrastructure</option>
<option value="communications">communications</option>
<option value="civilian">civilian</option>
<option value="industry">industry</option>
<option value="military units">military units</option>
</select>
<br>
<input type="button" value="Execute" onclick="executeQuery()" style = "background: transparent;">
<div id="query-results-container">
<h2>Results:</h2>
<table id="query-results">
</table>
</div>
</div>
<div class="share-buttons">
<a href="https://twitter.com/intent/tweet?url=https://github.com/Chen2023-UW/KosovoProject.git" target="_blank" rel="noopener noreferrer">
<img src="img/twitter.png" alt="share on Twitter">
</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=https://github.com/Chen2023-UW/KosovoProject.git" target="_blank" rel="noopener noreferrer">
<img src="img/facebook.png" alt="share on Facebook">
</a>
</div>
<div class="map-title-container">
<div id="map-title"><h1>NATO bombardovanje Jugoslavije, 1999</h1>
<i>(Operation Allied Force)</i></div>
</div>
<script type="text/javascript" src="lib/leaflet/leaflet.js"></script>
<script type="text/javascript" src="JS/map.js"></script>
<script type="text/javascript" src="JS/server.js"></script>
<script>
function executeQuery() {
const region = document.getElementById('region-select').value;
const month = document.getElementById('mon-select').value;
const type = document.getElementById('type-select').value;
const query = `SELECT location, region, type, month, day, descr, deaths FROM act1 WHERE
region='${region}'
AND month='${month}'
AND type='${type}'
Order by day ASC`;
fetch('http://localhost:3000/query', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ query: query }),
})
.then(response => response.json())
.then(data => {
const queryResultsElement = document.getElementById('query-results');
queryResultsElement.innerHTML = '';
const headerRow = document.createElement('tr');
for (const key in data[0]) {
const headerCell = document.createElement('th');
headerCell.textContent = key;
headerRow.appendChild(headerCell);
}
queryResultsElement.appendChild(headerRow);
data.forEach(result => {
const row = document.createElement('tr');
for (const key in result) {
const cell = document.createElement('td');
cell.textContent = result[key];
row.appendChild(cell);
}
queryResultsElement.appendChild(row);
});
})
.catch(error => {
console.error('Error executing query:', error);
});
}
</script>
</body>
</html>