word edit: js appends more multiinput columns
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 13 Jun 2020 14:32:25 +0000 (16:32 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 20 Oct 2020 20:49:11 +0000 (22:49 +0200)
Enter multiple option without requiring intermedia saves.

writer.js

index f05559ffa6a210dd9c91a84982dd06580c14f5c3..3f97e41ef8ecda2dce4309a7e154aff6a1c0c0e5 100644 (file)
--- a/writer.js
+++ b/writer.js
@@ -1,4 +1,16 @@
 document.addEventListener('DOMContentLoaded', () => {
+       document.querySelectorAll('.multiinput > input[id]').forEach(el => {
+               el.oninput = e => {
+                       if (e.target.value == '') return;
+                       let add = e.target.cloneNode(true);
+                       add.value = '';
+                       add.oninput = e.target.oninput;
+                       e.target.parentNode.appendChild(add);
+                       e.target.oninput = undefined;
+                       e.target.removeAttribute('id');
+               };
+       });
+
        let wpinput = document.getElementById('wptitle');
        if (wpinput) {
                let wpbutton = wpinput.parentNode.appendChild(document.createElement('button'));