Forráskód Böngészése

Add toggle for debug options

Added two checkboxes to turn on and off the console logging of the
code box and the stacks.
ApisNecros 1 éve
szülő
commit
753366a20b
2 módosított fájl, 15 hozzáadás és 3 törlés
  1. 10 2
      index.html
  2. 5 1
      starfish.js

+ 10 - 2
index.html

@@ -29,11 +29,19 @@
                 <textarea id="output" class="w-full bg-white font-mono border border-black" rows="20" disabled></textarea>
             </div>
         </div>
+        <div class="col-span-3">
+            <div>
+                <input id="debug-stacks" type="checkbox" />
+                <label for="debug-stacks">Debug: Display Stack</label>
+            </div> 
+            <div>
+                <input id="debug-code-box" type="checkbox" />
+                <label for="debug-code-box">Debug: Display Code Box</label>
+            </div> 
+        </div>
         <!-- <canvas class="w-full h-full"></canvas> -->
         <script>
             const cb = new CodeBox("script", "stackInit", "output");
-            cb.debug.print.codeBox = true;
-            cb.debug.print.stacks = true;
         </script>
     </body>
 </html>

+ 5 - 1
starfish.js

@@ -89,7 +89,7 @@ class CodeBox {
          *
          * @type {object}
          */
-        this.debug= {
+        this.debug = {
             print: {
                 codeBox: false,
                 stacks: false,
@@ -127,6 +127,10 @@ class CodeBox {
         this.outputDOM.value = "";
         console.clear();
 
+        // Set the debug values
+        this.debug.print.codeBox = document.getElementById("debug-code-box")?.checked;
+        this.debug.print.stacks = document.getElementById("debug-stacks")?.checked;
+
         const cbRaw = this.codeBoxDOM.value;
         const rows = cbRaw.split("\n");