diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 2d5b88ad..bf5efb46 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -368,4 +368,22 @@ let BookWyrm = new class { ); } } + + duplicateInput (input_id ) { + const orig = document.getElementById(input_id); + const parent = orig.parentNode; + const new_count = parent.querySelectorAll("input").length + 1 + + let input = orig.cloneNode(); + + input.id += ("-" + (new_count)) + input.value = "" + + let label = parent.querySelector("label").cloneNode(); + + label.setAttribute("for", input.id) + + parent.appendChild(label) + parent.appendChild(input) + } }(); diff --git a/bookwyrm/templates/book/edit/edit_book_form.html b/bookwyrm/templates/book/edit/edit_book_form.html index 982bb56d..841a3c53 100644 --- a/bookwyrm/templates/book/edit/edit_book_form.html +++ b/bookwyrm/templates/book/edit/edit_book_form.html @@ -119,10 +119,16 @@ {% endif %}