]> git.ardis.lu - minimal-srihash/commitdiff
Fix trailing newline when triple/quad clicking output
authorArdis Lu <ardisglu@gmail.com>
Thu, 10 Sep 2026 05:49:35 +0000 (22:49 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 10 Sep 2026 05:49:35 +0000 (22:49 -0700)
index.html

index 175720b602dc7e6dadbab1b48361e7f37c5caf54..b6443682f69520758c03ddbc76f02f52a44f7e9e 100644 (file)
 
     // Update code output on option checkbox or hash selection change
     document.querySelectorAll('input[type="checkbox"],select').forEach(e => e.addEventListener('change', () => form.requestSubmit()));
+
+    // Fix trailing newline on triple (or quad) click
+    const output = document.querySelector('output');
+    addEventListener('click', e => {
+      if (e.detail >= 3 && output.contains(e.target)) {
+        const range = document.createRange();
+        const textNode = output.firstChild.firstChild; // Assuming markup looks like <output><code>TEXT_NODE</code></output>
+        range.setStart(textNode, 0);
+        range.setEnd(textNode, textNode.length);
+        const selection = getSelection();
+        selection.removeAllRanges();
+        selection.addRange(range);
+      };
+    });
   </script>
 </body>
 
This page took 0.040212 seconds and 4 git commands to generate.