-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathlist.php
More file actions
115 lines (99 loc) · 2.89 KB
/
list.php
File metadata and controls
115 lines (99 loc) · 2.89 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CCAMS Mode S positions</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/style.css" rel="stylesheet">
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
</head>
<body>
<!-- Include Navbar -->
<?php include 'navbar.php'; ?>
<!-- Main Content -->
<div class="container mt-5">
<h1 class="mb-4">Airport List</h1>
<div class="mb-3">
<input type="text" id="filterInput" class="form-control" placeholder="Type to filter (use * / ?)">
</div>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>ICAO</th>
<th>Name</th>
<th>FIR</th>
</tr>
</thead>
<tbody id="airportTable">
<tr><td colspan="3" class="text-center">Loading...</td></tr>
</tbody>
</table>
</div>
</div>
<div id="debug" hidden="true"></div>
<!-- Footer -->
<footer class="bg-light text-center text-muted py-3">
Provided and maintained by Jonas Kuster
</footer>
<!-- Bootstrap JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<!-- Ajax -->
<script>
let airports = [];
// Wildcard matching function (* = any chars, ? = single char)
function wildcardMatch(pattern, str) {
if (!pattern) return true; // empty filter = match all
pattern = pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&'); // escape regex
pattern = pattern.replace(/\*/g, '.*').replace(/\?/g, '.');
const regex = new RegExp('^' + pattern + '$', 'i');
return regex.test(str);
}
// Load GeoJSON directly
$.getJSON('data/geojson/Airports_filtered.geojson', function(data) {
if (data.features) {
airports = data.features.map(f => ({
icao: f.properties.ICAO || '',
name: f.properties.Name || '',
fir: f.properties.FIR || ''
}));
renderTable(airports);
} else {
$('#airportTable').html('<tr><td colspan="3" class="text-center text-danger">Invalid GeoJSON</td></tr>');
}
});
// Render filtered table
function renderTable(list) {
const tbody = $('#airportTable');
tbody.empty();
if (list.length === 0) {
tbody.append('<tr><td colspan="3" class="text-center">No airports found.</td></tr>');
return;
}
$.each(list, function(i, airport) {
tbody.append(
`<tr>
<td>${airport.icao}</td>
<td>${airport.name}</td>
<td>${airport.fir}</td>
</tr>`
);
});
}
// Live filtering with wildcard
$('#filterInput').on('input', function() {
const filter = $(this).val().trim();
const filtered = airports.filter(a =>
wildcardMatch(filter, a.icao) ||
wildcardMatch(filter, a.name) ||
wildcardMatch(filter, a.fir)
);
renderTable(filtered);
});
</script>
</body>
</html>