-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdashboardsearch.html
180 lines (133 loc) · 5.89 KB
/
dashboardsearch.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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
<link rel="stylesheet" href="./assets/css/styles.css">
<link rel="stylesheet" href="./assets/css/line-colors.css">
<link rel="shortcut icon" type="image/x-icon" href="./assets/branding/favicon.ico">
<link rel="manifest" href="/manifest.json" type="application/json" >
<meta name="theme-color" content="#000">
<meta name="description" content="Verspätungs-Statistiken für Bahnhöfe.">
<meta name="keywords" content="verspätungen, verspätungsstatistik, pünktlichket, Pünktlichkeitsstatistik, Pünktlichkeits Statistik, bahn, db, bahnhof, deutschebahn, trainboard, abfahrtstafel, train, abfahrt, ankunft" />
<!-- Twitter Card Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Verspätungs-Statistiken für Bahnhöfe | Trainboard">
<meta name="twitter:description" content="Interaktives Verspätungsdahsboard für Bahnhöfe der EU.">
<meta name="twitter:image" content="https://trainboard.de.cool/assets/branding/bigdashboardbanner.png">
<meta name="twitter:url" content="https://trainboard.de.cool/dashboardsearch.html">
</head>
<body class="home">
<script src="./assets/src/widgets.js"></script>
<script src="./assets/src/pinnedPopup.js"></script>
<script src="./assets/src/twlngPopup.js"></script>
<!-- Info Popup -->
<div class="popuplinks">
<input type="checkbox" id="toggle">
<label for="toggle" class="toggle-label"></label>
<div class="content">
<span id="description"></span><br><small>provided by: <span id="copyright"></span></small>
<a href="about.html">
<div class="button">About</div>
</a>
<a href="https://github.com/hoolycrash/trainboard">
<div class="button githubbutton">Github</div>
</a>
</div>
</div>
<center>
<nav id="navbar">
<div class="tabs">
<a href="index.html" class=""> Zugtafel </a>
<a href="expert.html" class=""> Erweitert </a>
<a href="localsearch.html" class=""> Nahverkehr </a>
<a href="stationsearch.html" class=""> Bahnhof </a>
<a href="trainsearch.html" class=""> Zugsuche </a>
<span class="active"> Dashboard </span>
</div>
</nav>
<br> <br class="bigonly">
<table class="nameholder"><tr><td><img src="./assets/branding/icon-72x72.png" class="logo"></td><td class="wide bigtext">trainboard<span class="bigonly">.de.cool</span></td></tr></table>
<div class="searchcontainer">
<div class="container">
<input class="searchbar" type="text" autocomplete="off" id="searchInput" placeholder="Suche nach Station" oninput="searchLocations()" autofocus>
</div>
<div id="results"></div>
<hr>
<div style="margin: 15px;">
<span style="color: yellow;"><b>Wilkommen zurück 👋</b></span><br>
Auch große Teile von Trainboard sind weiterhin von der HAFAS-Abschaltung betroffen.<br>
Bitte beachtet dazu den Beitrag auf <a href="https://github.com/hoolycrash/trainboard/wiki/Unterbrechungen-durch-Abschaltung-von-HAFAS"><u>Github</u>.</a>
</div>
<!--
<br>
<font color="#ffe200"><b>Information:</b> Daten sind erst seit 25.10.2024 verfügbar. Einige Funktionen sind eingeschränkt.</font><br><br>--->
</div>
<br>
<script>
function searchLocations() {
const userInput = document.getElementById('searchInput').value;
const apiUrl = `https://data.cuzimmartin.dev/locations?query=${userInput}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => displayResults(data))
.catch(error => console.error('Error fetching data:', error));
}
function displayResults(data, searchType) {
const resultsContainer = document.getElementById('results');
resultsContainer.innerHTML = ''; // Clear previous results
data.forEach(entry => {
// Check if suburban is true
const isSuburban = entry.products.suburban === true;
const isRegional = entry.products.regional || entry.products.regionalexpress;
if (
entry.products.nationalExpress ||
entry.products.national ||
entry.products.regionalExpress ||
entry.products.regional ||
entry.products.suburban
) {
// Create a div with class "suggestion"
const suggestionDiv = document.createElement('div');
suggestionDiv.classList.add('suggestion');
// Create a span for the name
const nameSpan = document.createElement('span');
nameSpan.textContent = entry.name;
// Create an anchor element with a link based on the selected search type (departure or arrival)
const link = document.createElement('a');
link.href = `dashboard.html?stationID=${entry.id}`;
// If suburban is true, append an image to the link with class "bigicon"
if (isSuburban) {
const img = document.createElement('img');
img.src = './assets/icons/sbahn.svg';
img.alt = 'Suburban Icon';
img.classList.add('bigicon');
img.classList.add('inverted');
link.appendChild(img);
}
if (isRegional) {
const img = document.createElement('img');
img.src = './assets/icons/rail.svg';
img.alt = 'Rail Icon';
img.classList.add('bigicon');
img.classList.add('inverted');
link.appendChild(img);
}
// Append the nameSpan and link to the suggestionDiv
suggestionDiv.appendChild(nameSpan);
suggestionDiv.appendChild(link);
// Add a click event listener to the suggestionDiv
suggestionDiv.addEventListener('click', () => {
window.location.href = link.href; // Redirect to the link when the div is clicked
});
// Append the suggestionDiv to the results container
resultsContainer.appendChild(suggestionDiv);}
});
}
fetchAndDisplayData();
</script>
<script type="text/javascript" src="./assets/src/backgroundimage.js"></script>
</center>
</body>
</html>