Abstract control over checkboxs that disable stylesheet elements
authorKarl O. Pinc <kop@karlpinc.com>
Wed, 25 Sep 2024 18:28:47 +0000 (13:28 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Wed, 25 Sep 2024 18:28:47 +0000 (13:28 -0500)
src/pgwui_sql/static/pgwui_sql.js

index 0647153ab5759af79ecd943176e1e21e0a4ad65c..230a477e54d51163b4882874cf45aba228c96178 100644 (file)
@@ -52,8 +52,17 @@ function getTdSqltextSheet() {
             return sheet;
         }}}
 
-globalThis.tdSqltextSheet = getTdSqltextSheet();
-const show_spaces = document.getElementById('show_spaces_id');
-if (show_spaces !== null) {
-    whitespaceDisplay(show_spaces.checked);
+function initializeStyling() {
+    // Apply a checkbox when it exists
+    function applyCheckbox(id, initFunc) {
+        const elmt = document.getElementById(id);
+        if (elmt !== null) {
+            initFunc(elmt.checked);
+        }
+    }
+    applyCheckbox('show_spaces_id', whitespaceDisplay);
 }
+
+/* Initialization */
+globalThis.tdSqltextSheet = getTdSqltextSheet();
+initializeStyling();