+
+ /************************/
+ /* Set the service zone */
+ /************************/
+ function set_service_zone(event, zone) {
+ /* We can take the zone as a parameter too; this allows us to
+ * use this function for the (computed) MARC Train zone and
+ * not just the querystring Commuter Bus zone. The extra
+ * "event" parameter is there for the event listener, which
+ * would otherwise stuff an onload event into the zone
+ * parameter. "Thankfully" javascript lets us call a
+ * two-argument function with one argument and thereby abuse
+ * the event handler for this. */
+ const z = document.getElementById("zone");
+ const params = new URLSearchParams(document.location.search);
+
+ if (zone) {
+ z.textContent = zone;
+ z.style.display = "block"; /* It's hidden by default */
+ }
+ else if (params.get("zone")) {
+ /* Get the "zone" from the querystring if it's there */
+ z.textContent = params.get("zone");
+ z.style.display = "block"; /* It's hidden by default */
+ }
+
+ /* Otherwise, leave it blank (and hidden) */
+ }
+
+ /***********************************************************/
+ /* Resize the ticket background based on the service name */
+ /***********************************************************/
+
+ function resize_ticket() {
+ /* Get the "servicename" from the querystring if it's there */
+ const params = new URLSearchParams(document.location.search);
+ const tbg = document.getElementById("ticketbg");
+ const t = document.getElementById("ticket");
+ const sn = document.getElementById("servicename");
+
+ if (params.get("servicename") == "Commuter Bus") {
+ /* The top of the background is initially at y=246.859, and
+ * we scale it by a factor of 1.12 to y=276.482 for a change
+ * of 29.623. So after we scale it, we translate it upwards
+ * by that amount to put it back where it started. */
+ tbg.setAttribute("transform", "translate(0 -29.623) scale(1 1.12)");
+
+ /* Now translate the entire ticket up by the magic amount, 1/5
+ * of the size change we made to the background. This ratio
+ * was found by measuring pixels in side-by-side screenshots
+ * of BaltimoreLink and Commuter Bus tickets. */
+ t.setAttribute("transform", "translate(0 -9.33)");
+
+ /* More magic numbers discovered by comparing the two
+ * tickets overlayed in inkscape */
+ sn.setAttribute("transform", "translate(0 64.28)");
+ }
+ else if (params.get("servicename") == "MARC Train") {
+ /* insane tricks are explained above */
+ tbg.setAttribute("transform",
+ "translate(0 -72.378) scale(1 1.2932)");
+ t.setAttribute("transform", "translate(0 -67.17)");
+ sn.setAttribute("transform", "translate(0 131.0)");
+ }
+
+ /* Otherwise, leave it alone. The SVG was designed with the
+ * BaltimoreLink ticket in mind */
+ }
+