-
Notifications
You must be signed in to change notification settings - Fork 0
/
train-h.html
71 lines (62 loc) · 2.5 KB
/
train-h.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
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Transilien H</title>
<link rel="stylesheet" href="./css/app.css">
</head>
<body class="sncf">
<div class="menu">
<div>
<div class="logoLigne">
<img src="./img/lignes/train-h.svg" alt="">
</div>
<h1 id="station"></h1>
</div>
<div style="display: flex; flex-direction: column;">
<form action="">
<label for="stationSearch"></label>
<input type="text" id="stationSearch" oninput="rechercherStation()" placeholder="Saint-Lazare, ...">
<ul class="sncf" id="stationSearchResults"></ul>
</form>
</div>
</div>
<div id="horaires">
</div>
<script src="js/train-h.js"></script>
<script>
function rechercherStation() {
const inputValue = document.getElementById('stationSearch').value.toLowerCase();
const resultsContainer = document.getElementById('stationSearchResults');
resultsContainer.innerHTML = '';
jsonArrets.forEach(arret => {
const stopNameLowerCase = arret.stop_name.toLowerCase();
if (stopNameLowerCase.includes(inputValue)) {
const li = document.createElement('li');
li.textContent = arret.stop_name;
li.addEventListener('click', () => onStationClick(arret.stop_id, arret.stop_name));
resultsContainer.appendChild(li);
}
});
if (resultsContainer.children.length > 0) {
resultsContainer.style.display = 'block';
} else {
resultsContainer.style.display = 'none';
}
}
function onStationClick(stopId, stopName) {
console.log(`Stop ID: ${extractStopId(stopId)}, Stop Name: ${stopName}`);
document.getElementById('stationSearch').value = stopName;
document.getElementById('stationSearchResults').style.display = 'none';
updateHorairesv2(extractStopId(stopId));
stop_Id = extractStopId(stopId);
localStorage.setItem("stop_id", extractStopId(stopId))
prochainTrain()
}
function extractStopId(stopId) {
return stopId.split(':').pop(); // Extraire la dernière partie après le dernier ":"
}
</script>
</body>
</html>