-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·243 lines (212 loc) · 8.63 KB
/
index.php
File metadata and controls
executable file
·243 lines (212 loc) · 8.63 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Stats</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styler.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<!-- Chart.js 4.4.0 -->
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0"></script>
<!-- hammer.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
<!-- chartjs-plugin-zoom compatible with Chart.js 4.x -->
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-zoom@1.2.0"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
</head>
<body>
<div class="tabledis">
<div class="header-container">
<h1>Where are people using WindNinja?!</h1>
<a href="index.php" class="go-home-button">Go Home</a>
</div>
<br>
<!-- <div class="BIG">
<form method="post" class="form-horizontal">
<div class="grouper">
<label for="search">Search By Country, Region, City, Postal Code (no spaces):</label>
<input type="text" id="search" name="search" value="">
</div>
<input type="submit" value="Submit">
</form>
<form method="post" class="form-horizontal">
<div class="grouper">
<label for="year">Search by Year From:</label>
<input class="inp" type="text" id="year" name="year" value="">
<label for="year2">To: </label>
<input class="inp" type="text" id="year2" name="year2" value="">
</div>
<div class="grouper">
<label for="month">Search by Month From:</label>
<input class="inp" type="text" id="month" name="month" value="">
<label for="month2">To:</label>
<input class="inp" type="text" name="month2" id="month2" value="">
</div>
<div class="grouper">
<label for="day">Search by Day From:</label>
<input class="inp" type="text" id="day" name="day" value="">
<label for="day2">To:</label>
<input class="inp" type="text" id="day2" name="day2" value="">
</div>
<input type="submit" value="Submit">
</form>
</div> -->
<div class = "flexx">
<div id="map" style="height: 20vh;"></div>
<canvas id="myChart" style="width: 15vw;"></canvas>
<p id="totalRuns2025Display" style="margin-top: 10px;"></p>
<p id="totalUserDisplay" style="margin-top: 10px;"></p>
<p id="totalCountryDisplay" style="margin-top: 10px;"></p>
</div>
<br>
<?php include "markers.php"; ?>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
var totals = <?php echo $totalsJson; ?>;
var totals1 = <?php echo $totals1Json; ?>;
var totals2 = <?php echo $totals2Json; ?>;
var totals3 = <?php echo $totals3Json; ?>;
var markers = <?php echo $markersJson; ?>;
var markerszoom1 = <?php echo $markerszoomJson; ?>;
var timeint = <?php echo $timeintJson; ?>;
var timeint1 = <?php echo $timeintJson1; ?>;
var totalUnqiueUsers = <?php echo $uniqueUsersJson; ?>;
var totalCountries = <?php echo $totalCountriesJson; ?>;
var totalRuns2025 = <?php echo $totalRuns2025Json; ?>;
if (markerszoom1.length === 0) {
var map = L.map('map').fitBounds([
[24.396308, -125.0],
[49.384358, -66.93457]
]);
} else {
// Same for markerszoom1 condition
var map = L.map('map').fitBounds([
[24.396308, -125.0],
[49.384358, -66.93457]
]);
}
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
markers.forEach(function(marker) {
if (marker && marker.lat && marker.lat.split(',').length === 2) {
var lat = marker.lat.split(',')[0];
var lon = marker.lat.split(',')[1];
var popupContent = '<b>Marker Information</b><br>' +
'Latitude: ' + lat + '<br>' +
'Longitude: ' + lon + '<br>' + "Total WindNinja Runs: " + marker.total;
L.marker([lat, lon]).bindPopup(popupContent).addTo(map);
}
});
let combinedData = totals.map((dateStr, i) => ({
date: new Date(dateStr),
cli: totals1[i],
gui: totals2[i],
total: totals3[i]
}));
combinedData.sort((a, b) => a.date - b.date);
var dateObjects = combinedData.map(d => d.date);
var totals1Sorted = combinedData.map(d => d.cli);
var totals2Sorted = combinedData.map(d => d.gui);
var totals3Sorted = combinedData.map(d => d.total);
var maximum = dateObjects[dateObjects.length - 2];
var minimum = dateObjects[dateObjects.length - 5];
if (timeint != "") {
minimum = new Date(timeint);
maximum = new Date(timeint1);
}``
// Chart.js setup
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: dateObjects,
datasets: [
{
label: 'Total Ninja CLI Runs',
data: totals1Sorted,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1
},
{
label: 'Total Ninja GUI Runs',
data: totals2Sorted,
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1
},
{
label: 'Total Ninja Runs',
data: totals3Sorted,
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
}
]
},
options: {
responsive: true,
plugins: {
zoom: {
limits: {
y: { min: 0 } // Prevent zooming/panning below 0 on y-axis
},
pan: {
enabled: true,
mode: 'xy',
speed: 2,
threshold: 0
},
zoom: {
wheel: { enabled: true },
pinch: { enabled: true },
mode: 'xy'
}
}
},
scales: {
x: {
type: 'time',
time: {
unit: 'day',
tooltipFormat: 'll'
},
ticks: {
maxTicksLimit: 7,
autoSkip: false
},
min: minimum,
max: maximum
},
y: {
type: 'linear',
suggestedMin: 0,
grace: '5%',
}
}
}
});
setTimeout(() => {
const maxDate = new Date();
const minDate = new Date();
minDate.setDate(maxDate.getDate() - 8);
maxDate.setDate(maxDate.getDate() - 1);
myChart.zoomScale('x', {
min: minDate,
max: maxDate
});
myChart.zoom(0.999, 'xy');
}, 0);
document.getElementById('totalRuns2025Display').textContent =
'Total Runs (Year to date): ' + totalRuns2025.toLocaleString();
document.getElementById('totalUserDisplay').textContent =
'Total Users: ' + totalUnqiueUsers.toLocaleString();
document.getElementById('totalCountryDisplay').textContent =
'Total Countries: ' + totalCountries.toLocaleString();
});
</script>
<a href="https://ninjastorm.firelab.org/sqlitetest/placeholder.txt" download="stats.txt" class="download-link">
Download Text File of Stats</a>
</body>
</html>