Michael Orlitzky [Thu, 11 Sep 2025 14:21:21 +0000 (10:21 -0400)]
index.html.in,TODO: fix the QR placement issue
It turns out, we DON'T need to adjust our vertical offsets by the
svg-to-client unit ratio. I don't fully understand why, but I think it
has something to do with declaring the height of the tableau to be
fixed at 100% = 1080, and modern browsers treating "pixels" as an
abstraction. In any case, it works fine without the fudge factor in
both WebKit and Firefox.
Michael Orlitzky [Thu, 11 Sep 2025 03:40:52 +0000 (23:40 -0400)]
index.html.in: refactor the toggle_qr_focus() function
1. Adjust to the recent conversion of resize_ticket() to CSS
transforms.
2. Refine the ticket dimensions to match those of CharmPass.
This is still pretty hacky and may not work in all cases,
but on a fresh page load in a desktop browser, everything
is where it should be.
3. Simplify / clean up the code a little bit (using forEach,
classList, etc.)
Michael Orlitzky [Thu, 11 Sep 2025 03:33:55 +0000 (23:33 -0400)]
index.html.in: use svg_to_client() in center_text()
The center_text() function was the first place that a coordinate
change was needed, though it was in the other direction, client to
SVG. Now that we have the svg_to_client() factor, we divide by it to
get the client_to_svg factor.
Michael Orlitzky [Thu, 11 Sep 2025 03:13:01 +0000 (23:13 -0400)]
index.html.in: refactor resize_ticket() to use CSS transforms
While it would have been nice being able to revert to the initial
ticket size by erasing the CSS "transform", doing so makes the
transitions wonky: with Commuter Bus and MARC Train tickets, it first
transitions down to the BaltimoreLink ticket size, and then back up to
the initial attribute-based size.
Michael Orlitzky [Thu, 11 Sep 2025 03:03:53 +0000 (23:03 -0400)]
index.html.in: two transition fixes
First, the repositioning of the ticket also needs to be transitioned.
This makes the QR animation much smoother.
Second, it would seem that appending the "loaded" class (to enable
transitions) can retroactively affect style changes that were made
before the class was appended. The workaround for this is to do
something that makes the browser re-flow the affected elements, and I
guess calling focus() suffices to do that. So we add in a call to
focus() before appending the "loaded" class to the ticket and its
background; this ensures that the transitions are not enabled until
after the initial ticket sizing, as was always the intent.
Michael Orlitzky [Thu, 11 Sep 2025 01:58:09 +0000 (21:58 -0400)]
index.html.in: factor out the svg_to_client() function
This will waste a tiiiiny bit of time because we only call this
function in contexts where we already have the security code
background element handy (and the new function recomputes it),
but it's so much cleaner as a separate function.
Michael Orlitzky [Wed, 10 Sep 2025 23:58:39 +0000 (19:58 -0400)]
index.html.in: fix QR focus for Commuter Bus and MARC train
These need their initial upwards translations "repeated" when the QR
code is focused and we overwrite the transform attribute with CSS.
The scale() just works, but that's because these ticket start at the
correct scale -- not true of their position.
Michael Orlitzky [Wed, 10 Sep 2025 23:26:47 +0000 (19:26 -0400)]
index.html.in: make ticket taps do nothing
Tapping the ticket (anything but the QR code) in CharmPass does
nothing; i.e. it does not change the background from day to night.
We mimic that with a dummy click handler on the ticket.
Michael Orlitzky [Wed, 10 Sep 2025 14:30:19 +0000 (10:30 -0400)]
index.html.in: finish the QR focus toggle
Get the QR focus toggle working "completely."
* Don't show ticket resize transitions when the page loads
(Commuter bus / MARC).
* Fade out the origin/destination and zone when the QR is
focused (Commuter bus / MARC).
* Resize the bottom portion of the ticket when the QR code
is focused, so that the QR sits in the "middle" like it
does on CharmPass.
* Don't recompute dimensions if we're going to toggle the
QR code _off_.
BaltimoreLink tickets are essentially correct. I have yet to compare
against real Commuter bus and MARC train tickets, but the current
behavior is reasonable.
Reimplement the sizing of the commuter bus and MARC train tickets to
account for the split top and bottom halves of the ticket. This is not
too difficult because, this time around, we take advantage of the
transform-box and transform-origin properties to scale only the bottom
half of the ticket, and only downwards.
The new magic numbers were found by comparing old/new versions of the
page in two separate browser tabs. This also happens to fix the
alignment of the grey ticket separator, because the top half of the
ticket (that contains it) is no longer being scaled
1. The ticket separator becomes misaligned when you scale the
ticket background independently
2. Only the bottom of the ticket is resized when the QR gains
focus.
Both of these will be easier if we split the bottom part of the ticket
from the top (separator, dimples, and the stuff above them). This
commit does that. The top/bottom parts aren't grouped because we
probably won't need to manipulate them as groups, so for now, there
are just two ticket background layers with an epsilon of overlap.
Tapping the QR code now brings it into focus and centers it in the
ticket, accompanied by a nice CSS transition that mimics the real
thing. The timing was adjusted to make the transition faster, and a
portability issue was hacked around. What does work, works in both
Firefox and WebKit (on the desktop) at least.
Still to-do is the ticket resizing that takes place when the QR code
gets bigger, and the vertical translation of the (growing) QR code.
tableau.svg: group QR code with a (white, "invisible") background
The QR code is a path, so the "click" handler that we want to write
for it will only work if the thin black squiggle is tapped. To work
around that, we add a square white background behind the squiggle that
is the same color as the ticket. Afterwards, the "QR code" consists of
the black squiggle and the square; you can click on either.
Whatever problem was preventing us from swapping day/night colors via
CSS classes is gone. Or at least hiding in a browser that I don't have
in front of me.
tableau.svg: less rounding on the code background's corners
Just like the ticket background, the background on the security code
has had its corners un-rounded a bit in the latest version of
CharmPass. Turn ours down from 10 to 5.75 to match.
tableau.svg: less rounding on ticket background corners
The June 2025 CharmPass has slightly less rounding on the corners of
the tickets, and it actually is noticeable. Update the corners of our
ticket to match.
index.html.in: remove links to my personal website
The MTA just sent me a cease and desist for charm-bypass.com, which I
intend to honor. But if somebody else wants to... *shrug* then my name
shouldn't be plastered all over the page.
Michael Orlitzky [Wed, 13 Dec 2023 00:25:26 +0000 (19:25 -0500)]
index.html.in: add New Carrollton MARC info
The code for New Carrollton is NCR (thanks you-know-who), and it's on
the Penn Line, so all we have to do is fill in the zone information
based on the CharmPass prices to each of the other Penn destinations.
Michael Orlitzky [Wed, 13 Dec 2023 00:13:56 +0000 (19:13 -0500)]
index.html.in: add Frederick <-> Washington MARC info
Both Frederick and Washington D.C. are on the Brunswick line, and the
code for Frederick is FRC (thanks you-know-who). The cost of that
ticket is $9 in CharmPass, so that's a Four Zone.
Michael Orlitzky [Tue, 12 Dec 2023 21:00:20 +0000 (16:00 -0500)]
cgi-bin/code.cgi: new CGI script to update the daily code on a web host
This isn't really part of CharmBypass, but it will come in handy on
charm-bypass.com, and where else to put it? It's a CGI script that
allows visitors to update the code. You should probably password
protect it and make it available only to trusted users.
The script is written in POSIX shell script. Why? Because I didn't
really want to venture beyond a single-page, off-line, static HTML
file. But writing a CGI script in POSIX shell was just too dumb to say
no to. It uses sed to parse/edit index.html. Everything about it is
bad.
It can be tested with "python -m http.server --cgi", but the 302
redirect won't work because python doesn't support it.
tableau.svg: overlap the city and its copy by one unit
This fixes a display glitch where there's one pixel of space visible
between the end of the city (or its copy) and the beginning of its
copy (or the original).
tableau.svg: strip all stroke-foo properties that follow stroke:none
Inkscape crams all of these properties into the file, I guess so that
information isn't lost if you disable and re-enable the stroke on some
element. And most of them are stripped during minimization, but a
bunch of impotent stroke-widths make it through to the final document.
I've stripped all of it by hand, since removing it all was just as
easy as removing the stroke-width.
tableau.svg: shrink/translate everything down to width=2932
Previously, we had width=2932.6 and a matching viewport. It shouldn't
matter when a viewport is defined, but in the interest of pedantry:
SVG2 punts to CSS2.1 for the width, and CSS2.1 doesn't support user
(SVG internal) coordinates. Instead, width=2932.6 would represent
pixels, and 0.6 pixels doesn't make sense. We avoid the non-issue by
shrinking/translating things a tiny bit.
index.html.in: also validate the origin/destination when the page loads
Firefox (at least) retains your origin/destination selections when the
page reloads, so if we don't validate those choices at page load, it's
possible to "skip" validation of an invalid pair by submitting the
form right after a reload.