From db204009c315bda2f7b59fc2b3dabc637ddcf078 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 26 Oct 2023 18:49:47 -0400 Subject: [PATCH] index.html.in: center the security code even harder Doing it five times works better than two (obviously). --- index.html.in | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/index.html.in b/index.html.in index 0ad89dc..44b31c5 100644 --- a/index.html.in +++ b/index.html.in @@ -306,10 +306,15 @@ ct.setAttribute("x", parseFloat(ct.getAttribute("x")) + hdelta); } - function center_code_wrapper() { - /* Lets us call center_code twice on page load. Why we need to - * do this is an interesting (i.e. stupid) conversation. */ - center_code(); + function center_code_repeatedly() { + /* Lets us call center_code five times on page load. Why we + * need to do this is an interesting (i.e. stupid) topic for + * conversation. */ + center_code(); + center_code(); + center_code(); + center_code(); + center_code(); } /*****************************************/ @@ -382,16 +387,14 @@ /* Set the security code text when the page has loaded */ window.addEventListener("load", set_code); - /* Center the security code text when the page has loaded; - * in particular, after we set it. And then center it again. - * Why? I'm glad you asked. Because it doesn't actually get - * centered the first time; it's off by a few pixels. But then - * if we center it _again_, I guess we're so close to begin with - * that any errors aren't noticeable. Anyway, just running it - * twice in a row avoids a major headache. We need the wrapper - * because the spec says that duplicate handlers are discarded. */ - window.addEventListener("load", center_code); - window.addEventListener("load", center_code_wrapper); + /* Center the security code text when the page has loaded; in + * particular, after we set it. And then center it again. And + * again and again and again. Why? I'm glad you asked. Because + * it doesn't actually get centered the first time; it's off by + * a few pixels. But then if we center it _again_, it moves a + * little closer to the true center. Do that enough times and + * any errors become unnoticeable. */ + window.addEventListener("load", center_code_repeatedly); /* Re-center the security code when the window is resized, * and in particular after the ticket is re-centered */ -- 2.44.2