<style>
input[type=submit] {
- margin-top: 1em;
- margin-bottom: 1em;
+ margin-top: 1em;
+ margin-bottom: 1em;
}
svg {
#citycopy {
/* The city moves faster than the clouds but slower
* than the trees */
- animation: citycopyscroll 35s linear infinite;
+ animation: citycopyscroll 35s linear infinite;
}
</style>
</head>
}
}
+
+ /*******************************************************/
+ /* Compute the MARC "zone" from its origin/destination */
+ /*******************************************************/
+
+ /* Sorted on the first component, then the second */
+ const zone_map = {
+ BAL_BWE: 2,
+ BAL_SEB: 3,
+ BAL_WAS: 4,
+ BCA_CPK_: 3,
+ BWI_WBL: 1
+ };
+
+ /* The default. Obviously wrong for when we don't
+ * have the necessary data. */
+ let zone = 0;
+
+ function compute_marc_zone(src, dest) {
+ /* Forward direction key for zone_map */
+ const fwd = src + "_" + dest;
+
+ /* Reverse direction key for zone_map. The zone_map only
+ * has them listed in one direction, so we check both
+ * directions here. */
+ const rev = dest + "_" + src;
+
+ if (zone_map[fwd]) {
+ zone = zone_map[fwd];
+ }
+ else if (zone_map[rev]) {
+ zone = zone_map[rev];
+ }
+
+ /* Convert the number to a string */
+ switch (zone) {
+ case 1:
+ return "One Zone";
+ case 2:
+ return "Two Zone";
+ case 3:
+ return "Three Zone";
+ case 4:
+ return "Four Zone";
+ default:
+ return "??? Zone";
+ }
+ }
+
+ function set_marc_zone() {
+ const params = new URLSearchParams(document.location.search);
+ if (params.get("origin") && params.get("destination")) {
+ const src = params.get("origin");
+ const dest = params.get("destination");
+ const zone = compute_marc_zone(src, dest);
+
+ /* TODO: actually set the zone */
+ alert(zone);
+ }
+ }
+
/******************************************/
/* 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 zone, if applicable */
+ window.addEventListener("load", set_marc_zone);
+
/* Swap colors when the screen is tapped */
document.body.addEventListener("click", swap_colors);
}