Skip to content

Commit

Permalink
improve code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
luttje committed Sep 27, 2024
1 parent 5b66a7c commit e31acaf
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
60 changes: 50 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Bus tijden</title>

<meta http-equiv="Content-Security-Policy"
content="upgrade-insecure-requests">

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<script>
Expand All @@ -23,9 +25,7 @@
}
}
</script>
</head>

<body>
<style>
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville&family=Montserrat&family=Open+Sans&display=swap');

Expand All @@ -39,12 +39,17 @@

}
</style>
</head>

<body>
<div id="app">
{{getData}}

<div class="toCentral text-curioText">
<h2 class="text-3xl bg-curioGreen text-curioPurple font-bold uppercase p-3">
Centraal <span class="text-base font-normal">( <b>Let op:</b> tijden zonder looptijd )</span>
</h2>

<table class="table-auto w-full">
<thead class="text-l bg-curioGreen text-curioPurple uppercase">
<tr class="text-center">
Expand All @@ -54,6 +59,7 @@ <h2 class="text-3xl bg-curioGreen text-curioPurple font-bold uppercase p-3">
<th class="p-1">Lijn</th>
</tr>
</thead>

<tbody class="text-2xl">
<tr v-for="bus in toCentral.slice(0,5)"
class="text-center border-b">
Expand All @@ -73,10 +79,12 @@ <h2 class="text-3xl bg-curioGreen text-curioPurple font-bold uppercase p-3">
</tbody>
</table>
</div>

<div class="toRoute text-curioText">
<h2 class="text-3xl bg-curioGreen text-curioPurple font-bold uppercase p-3">
Route <span class="text-base font-normal">( <b>Let op:</b> tijden zonder looptijd )</span>
</h2>

<table class="table-auto w-full">
<thead class="text-1 bg-curioGreen text-curioPurple uppercase">
<tr class="text-center">
Expand All @@ -86,6 +94,7 @@ <h2 class="text-3xl bg-curioGreen text-curioPurple font-bold uppercase p-3">
<th class="p-1">Lijn</th>
</tr>
</thead>

<tbody class="text-2xl">
<tr v-for="bus in toRoute.slice(0,5)"
class="text-center border-b">
Expand All @@ -105,9 +114,21 @@ <h2 class="text-3xl bg-curioGreen text-curioPurple font-bold uppercase p-3">
</tbody>
</table>
</div>

<br />
</div>

<script>
const TO_CENTRAL_ID = 72000640;
const TO_ROUTE_ID = 72000810;

function sortPasses(passes) {
return Object.values(passes)
.sort(
(a, b) => a.TargetArrivalTime.localeCompare(b.TargetArrivalTime)
);
}

Vue.createApp({
data() {
return {
Expand All @@ -117,19 +138,38 @@ <h2 class="text-3xl bg-curioGreen text-curioPurple font-bold uppercase p-3">
},
computed: {
getData() {
const url = 'https://bustijden.curio.codes';
let options = {
let url = 'https://bustijden.curio.codes';
const options = {
method: 'GET'
}
let response = fetch(url, options).then((response) => response.json()).then((data) => {
this.toCentral = Object.values(data.BdOud[72000640].Passes).sort((a, b) => a.TargetArrivalTime.localeCompare(b.TargetArrivalTime));
this.toRoute = Object.values(data.BdOud[72000810].Passes).sort((a, b) => a.TargetArrivalTime.localeCompare(b.TargetArrivalTime));
});

if (window.location.hostname === 'localhost'
|| window.location.hostname === '127.0.0.1') {
// Note that you will have to open this URL in the browser and accept the risk
// before it will load the data.
url = 'http://v0.ovapi.nl/stopareacode/BdOud';

// If you want live data, comment the line below. We use this static data during
// development to prevent hitting any API rate limit.
url = 'test-data.json';
}

fetch(url, options)
.then((response) => response.json())
.then((data) => {
this.toCentral = sortPasses(data.BdOud[TO_CENTRAL_ID].Passes);
this.toRoute = sortPasses(data.BdOud[TO_ROUTE_ID].Passes);
});
}
},
methods: {
formatDate(value) {
return new Date(value).toLocaleTimeString('nl-NL', { hour: '2-digit', minute: '2-digit', second: '2-digit' });
return new Date(value)
.toLocaleTimeString('nl-NL', {
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
},
translate(status) {
let translatedStatus;
Expand All @@ -148,7 +188,7 @@ <h2 class="text-3xl bg-curioGreen text-curioPurple font-bold uppercase p-3">
translatedStatus = 'Rijden';
break;
default:
translatedStatus = 'Onbekend'; // Default translation for unknown status
translatedStatus = 'Onbekend';
}

return translatedStatus;
Expand Down
1 change: 1 addition & 0 deletions test-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"BdOud":{"72000640":{"Stop":{"Longitude":3.3135424,"Latitude":47.974766,"TimingPointTown":"Breda","TimingPointName":"Oude Baan","TimingPointCode":"72000640","StopAreaCode":"BdOud","TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"Passes":{"ARR_20240927_23123_1082_0":{"IsTimingStop":true,"DestinationName50":"Centraal Station","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1082,"JourneyPatternCode":2009103318,"LocalServiceLevelCode":20240927,"LineDirection":1,"OperationDate":"2024-09-27","TimingPointCode":"72000640","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Made - Raamsdonksveer","LinePublicNumber":"123","LastUpdateTimeStamp":"2024-09-27T18:43:30+0200","DestinationCode":"9200","ExpectedDepartureTime":"2024-09-27T19:28:00","UserStopOrderNumber":25,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23123","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"DRIVING","UserStopCode":"72000640","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:28:00","TargetDepartureTime":"2024-09-27T19:28:00","ExpectedArrivalTime":"2024-09-27T19:28:00","NumberOfCoaches":1,"TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23117_1054_0":{"IsTimingStop":true,"DestinationName50":"Centraal Station","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1054,"JourneyPatternCode":1333403961,"LocalServiceLevelCode":20240927,"LineDirection":1,"OperationDate":"2024-09-27","TimingPointCode":"72000640","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Zevenbergen - Fijnaart","LinePublicNumber":"117","LastUpdateTimeStamp":"2024-09-27T18:54:04+0200","DestinationCode":"9370","ExpectedDepartureTime":"2024-09-27T19:05:00","UserStopOrderNumber":21,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23117","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"DRIVING","UserStopCode":"72000640","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:05:00","TargetDepartureTime":"2024-09-27T19:05:00","ExpectedArrivalTime":"2024-09-27T19:05:00","NumberOfCoaches":1,"TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23123_1080_0":{"IsTimingStop":true,"DestinationName50":"Centraal Station","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1080,"JourneyPatternCode":2009103318,"LocalServiceLevelCode":20240927,"LineDirection":1,"OperationDate":"2024-09-27","TimingPointCode":"72000640","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Made - Raamsdonksveer","LinePublicNumber":"123","LastUpdateTimeStamp":"2024-09-27T18:15:40+0200","DestinationCode":"9200","ExpectedDepartureTime":"2024-09-27T19:02:00","UserStopOrderNumber":25,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23123","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"DRIVING","UserStopCode":"72000640","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:02:00","TargetDepartureTime":"2024-09-27T19:02:00","ExpectedArrivalTime":"2024-09-27T19:02:00","NumberOfCoaches":1,"TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23117_1056_0":{"IsTimingStop":true,"DestinationName50":"Centraal Station","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1056,"JourneyPatternCode":1333403961,"LocalServiceLevelCode":20240927,"LineDirection":1,"OperationDate":"2024-09-27","TimingPointCode":"72000640","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Zevenbergen - Fijnaart","LinePublicNumber":"117","LastUpdateTimeStamp":"2024-09-27T18:42:13+0200","DestinationCode":"9370","ExpectedDepartureTime":"2024-09-27T19:34:00","UserStopOrderNumber":21,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23117","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"DRIVING","UserStopCode":"72000640","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:34:00","TargetDepartureTime":"2024-09-27T19:34:00","ExpectedArrivalTime":"2024-09-27T19:34:00","NumberOfCoaches":1,"TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23122_1034_0":{"IsTimingStop":true,"DestinationName50":"Centraal Station","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1034,"JourneyPatternCode":37482413,"LocalServiceLevelCode":20240927,"LineDirection":1,"OperationDate":"2024-09-27","TimingPointCode":"72000640","WheelChairAccessible":"UNKNOWN","LineName":"Breda - Lage Zwaluwe","LinePublicNumber":"122","LastUpdateTimeStamp":"2024-09-18T22:48:16+0200","DestinationCode":"9370","ExpectedDepartureTime":"2024-09-27T20:13:00","UserStopOrderNumber":15,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23122","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"PLANNED","UserStopCode":"72000640","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T20:13:00","TargetDepartureTime":"2024-09-27T20:13:00","ExpectedArrivalTime":"2024-09-27T20:13:00","TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23122_1032_0":{"IsTimingStop":true,"DestinationName50":"Centraal Station","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1032,"JourneyPatternCode":37482413,"LocalServiceLevelCode":20240927,"LineDirection":1,"OperationDate":"2024-09-27","TimingPointCode":"72000640","WheelChairAccessible":"UNKNOWN","LineName":"Breda - Lage Zwaluwe","LinePublicNumber":"122","LastUpdateTimeStamp":"2024-09-27T18:39:17+0200","DestinationCode":"9370","ExpectedDepartureTime":"2024-09-27T19:13:00","UserStopOrderNumber":15,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23122","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"DRIVING","UserStopCode":"72000640","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:13:00","TargetDepartureTime":"2024-09-27T19:13:00","ExpectedArrivalTime":"2024-09-27T19:13:00","NumberOfCoaches":1,"TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23117_1058_0":{"IsTimingStop":true,"DestinationName50":"Centraal Station","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1058,"JourneyPatternCode":1333403961,"LocalServiceLevelCode":20240927,"LineDirection":1,"OperationDate":"2024-09-27","TimingPointCode":"72000640","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Zevenbergen - Fijnaart","LinePublicNumber":"117","LastUpdateTimeStamp":"2024-09-27T02:21:57+0200","DestinationCode":"9370","ExpectedDepartureTime":"2024-09-27T19:58:00","UserStopOrderNumber":21,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23117","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"PLANNED","UserStopCode":"72000640","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:58:00","TargetDepartureTime":"2024-09-27T19:58:00","ExpectedArrivalTime":"2024-09-27T19:58:00","TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23123_1084_0":{"IsTimingStop":true,"DestinationName50":"Centraal Station","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1084,"JourneyPatternCode":2009103318,"LocalServiceLevelCode":20240927,"LineDirection":1,"OperationDate":"2024-09-27","TimingPointCode":"72000640","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Made - Raamsdonksveer","LinePublicNumber":"123","LastUpdateTimeStamp":"2024-09-27T02:17:04+0200","DestinationCode":"9200","ExpectedDepartureTime":"2024-09-27T19:58:00","UserStopOrderNumber":25,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23123","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"PLANNED","UserStopCode":"72000640","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:58:00","TargetDepartureTime":"2024-09-27T19:58:00","ExpectedArrivalTime":"2024-09-27T19:58:00","TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"}},"GeneralMessages":{}},"72000810":{"Stop":{"Longitude":3.3135424,"Latitude":47.974766,"TimingPointTown":"Breda","TimingPointName":"Oude Baan","TimingPointCode":"72000810","StopAreaCode":"BdOud","TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"Passes":{"ARR_20240927_23123_1079_0":{"IsTimingStop":true,"DestinationName50":"Raamsdonksveer","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1079,"JourneyPatternCode":1392668317,"LocalServiceLevelCode":20240927,"LineDirection":2,"OperationDate":"2024-09-27","TimingPointCode":"72000810","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Made - Raamsdonksveer","LinePublicNumber":"123","LastUpdateTimeStamp":"2024-09-27T02:17:07+0200","DestinationCode":"9561","ExpectedDepartureTime":"2024-09-27T20:02:00","UserStopOrderNumber":3,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23123","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"PLANNED","UserStopCode":"72000810","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T20:02:00","TargetDepartureTime":"2024-09-27T20:02:00","ExpectedArrivalTime":"2024-09-27T20:02:00","TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23123_1077_0":{"IsTimingStop":true,"DestinationName50":"Raamsdonksveer","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1077,"JourneyPatternCode":1392668317,"LocalServiceLevelCode":20240927,"LineDirection":2,"OperationDate":"2024-09-27","TimingPointCode":"72000810","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Made - Raamsdonksveer","LinePublicNumber":"123","LastUpdateTimeStamp":"2024-09-27T18:24:13+0200","DestinationCode":"9561","ExpectedDepartureTime":"2024-09-27T19:02:00","UserStopOrderNumber":3,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23123","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"DRIVING","UserStopCode":"72000810","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:02:00","TargetDepartureTime":"2024-09-27T19:02:00","ExpectedArrivalTime":"2024-09-27T19:02:00","NumberOfCoaches":1,"TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23122_1033_0":{"IsTimingStop":true,"DestinationName50":"Lage Zwaluwe","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1033,"JourneyPatternCode":1777951052,"LocalServiceLevelCode":20240927,"LineDirection":2,"OperationDate":"2024-09-27","TimingPointCode":"72000810","WheelChairAccessible":"UNKNOWN","LineName":"Breda - Lage Zwaluwe","LinePublicNumber":"122","LastUpdateTimeStamp":"2024-09-18T22:48:16+0200","DestinationCode":"9500","ExpectedDepartureTime":"2024-09-27T19:13:00","UserStopOrderNumber":3,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23122","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"PLANNED","UserStopCode":"72000810","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:13:00","TargetDepartureTime":"2024-09-27T19:13:00","ExpectedArrivalTime":"2024-09-27T19:13:00","TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"},"ARR_20240927_23117_1055_0":{"IsTimingStop":true,"DestinationName50":"Klundert","DataOwnerCode":"ARR","OperatorCode":"BRAVO:ARR","FortifyOrderNumber":0,"TransportType":"BUS","Latitude":47.974766,"Longitude":3.3135424,"JourneyNumber":1055,"JourneyPatternCode":1360519228,"LocalServiceLevelCode":20240927,"LineDirection":2,"OperationDate":"2024-09-27","TimingPointCode":"72000810","WheelChairAccessible":"UNKNOWN","LineName":"Breda via Zevenbergen - Fijnaart","LinePublicNumber":"117","LastUpdateTimeStamp":"2024-09-27T02:18:05+0200","DestinationCode":"9498","ExpectedDepartureTime":"2024-09-27T19:35:00","UserStopOrderNumber":3,"ProductFormulaType":"EMPTY","TimingPointName":"Oude Baan","LinePlanningNumber":"23117","StopAreaCode":"BdOud","TimingPointDataOwnerCode":"ALGEMEEN","TimingPointTown":"Breda","TripStopStatus":"PLANNED","UserStopCode":"72000810","JourneyStopType":"INTERMEDIATE","TargetArrivalTime":"2024-09-27T19:35:00","TargetDepartureTime":"2024-09-27T19:35:00","ExpectedArrivalTime":"2024-09-27T19:35:00","TimingPointWheelChairAccessible":"ACCESSIBLE","TimingPointVisualAccessible":"ACCESSIBLE"}},"GeneralMessages":{}}}}

0 comments on commit e31acaf

Please sign in to comment.