diff --git a/web/api.js b/web/api.js index a5c2372..fc5131b 100644 --- a/web/api.js +++ b/web/api.js @@ -1,6 +1,8 @@ export function fetchApi(pathcomponents, query) { + console.log(pathcomponents); query.pretty = true; - let url = '/api/' + pathcomponents.join("/") + "?" + new URLSearchParams(query).toString(); + let url = '/api/' + pathcomponents.map(component => encodeURIComponent(component)).join("/") + "?" + new URLSearchParams(query).toString(); + console.log(url); return fetch(url).then(response => { if (!response.ok) { throw new Error("Fetching api failed"); @@ -26,3 +28,7 @@ export function fetchJourneys(from_, to) { to: to, }); } + +export function fetchTrip(trip_id) { + return fetchApi(["trips", trip_id], {}); +} diff --git a/web/drafting-board.js b/web/drafting-board.js index 6103a95..4d97703 100644 --- a/web/drafting-board.js +++ b/web/drafting-board.js @@ -1,4 +1,5 @@ import { EL } from "./dom.js"; +import { displayTripDetails } from "./trip-details.js"; let element_board = document.querySelector("#drafting-board-content"); @@ -91,6 +92,12 @@ export function addJourneyToDraftingBoard(journey) { }, }); el_trip.innerText = leg?.line?.name; + + el_trip.addEventListener("click", event => { + console.log(leg.tripId); + displayTripDetails(leg.tripId); + }); + element_board.appendChild(el_trip); let el_trip_right = EL("div", { diff --git a/web/index.html b/web/index.html index 7805225..1863cec 100644 --- a/web/index.html +++ b/web/index.html @@ -46,5 +46,14 @@ + +