]> gitweb.michael.orlitzky.com - charm-bypass.git/commitdiff
index.html.in: set the MARC origin/destination when applicable
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 3 Nov 2023 03:02:50 +0000 (23:02 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 3 Nov 2023 03:19:08 +0000 (23:19 -0400)
index.html.in

index 96dd04a437b2dab5ae75e188045850419311e235..1584284c0db404712d0ace4dc40ea9eced114ac8 100644 (file)
@@ -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;
       }
 
         }
       }
 
+
+      /*****************************************************/
+      /* 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) */
       /******************************************/
         /* 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);