From 5dd869987b5ea2e665959ac176c18c5808062c9c Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 10 Sep 2025 21:58:09 -0400 Subject: [PATCH] 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. --- index.html.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.html.in b/index.html.in index 3d1ec0b..244f742 100644 --- a/index.html.in +++ b/index.html.in @@ -584,6 +584,17 @@ } + /** + * Convert SVG units into client (HTML/CSS) units based + * on the declared/rendered width of the code background. + */ + function svg_to_client() { + const codebg = document.getElementById("codebg"); + const client_width = codebg.getBoundingClientRect().width; + const svg_width = parseFloat(codebg.getAttribute("width")); + return client_width / svg_width; + } + /** * Resize the ticket background based on the service name. * The BaltimoreLink, Commuter Bus, and MARC Train tickets -- 2.49.0