From: Michael Orlitzky Date: Thu, 11 Sep 2025 01:58:09 +0000 (-0400) Subject: index.html.in: factor out the svg_to_client() function X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=5dd869987b5ea2e665959ac176c18c5808062c9c;p=charm-bypass.git 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. --- 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