From: Michael Orlitzky Date: Fri, 3 Nov 2023 03:02:50 +0000 (-0400) Subject: index.html.in: set the MARC origin/destination when applicable X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=c7dd518626122b5e76e5a9bdfd208d06a425df6b;p=charm-bypass.git index.html.in: set the MARC origin/destination when applicable --- diff --git a/index.html.in b/index.html.in index 96dd04a..1584284 100644 --- a/index.html.in +++ b/index.html.in @@ -55,7 +55,7 @@ url("data:font/woff2;base64,@CBPREGULAR@") format("woff2") } - #servicename, #tickettime, #ticketdate, #codetext, #zone { + #origindest, #servicename, #tickettime, #ticketdate, #codetext, #zone { font-family: "CharmBypass Regular", sans-serif; } @@ -701,6 +701,32 @@ } } + + /*****************************************************/ + /* Set the origin and destination for the MARC Train */ + /*****************************************************/ + + function set_marc_origin_destination() { + const params = new URLSearchParams(document.location.search); + if (!params.get("origin") || !params.get("destination")) { + return; + } + + const src = params.get("origin"); + const dest = params.get("destination"); + + /* origindest contains both the origin and destination */ + const origindest = document.getElementById("origindest"); + + const origin = document.getElementById("origin"); + const destination = document.getElementById("destination"); + + origin.textContent = params.get("origin"); + destination.textContent = params.get("destination"); + + origindest.style.display = "block"; /* It's hidden by default */ + } + /******************************************/ /* Display the ticket (and hide the menu) */ /******************************************/ @@ -756,6 +782,9 @@ /* Set the ticket expiration date/time upon page load */ window.addEventListener("load", set_ticket_expiry); + /* Set the MARC Train origin and destination, if applicable */ + window.addEventListener("load", set_marc_origin_destination); + /* Set the MARC Train zone, if applicable */ window.addEventListener("load", set_marc_zone);