summaryrefslogtreecommitdiff
path: root/haunt/static/js
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2023-03-24 17:35:13 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2023-03-24 17:36:23 -0400
commit05de590c934cae434c62d6f71605b7ce7d23348e (patch)
tree2686c416b4bba23e761e6dbea29a30a5650acb0b /haunt/static/js
parentf0e1a3a9a79629197736c39a5feddac2e83dd8ae (diff)
Finalize capabilityfeature/static-rsvp-form
Diffstat (limited to 'haunt/static/js')
-rw-r--r--haunt/static/js/rsvp-min.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/haunt/static/js/rsvp-min.js b/haunt/static/js/rsvp-min.js
new file mode 100644
index 0000000..8c6d053
--- /dev/null
+++ b/haunt/static/js/rsvp-min.js
@@ -0,0 +1,49 @@
+/*
+ * rsvp-min.js -- UX improvements for static RSVP form page.
+ * Copyright © 2023 Jakob L. Kreuze <zerodaysfordays@sdf.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+// Common nodes.
+const guestView = document.getElementById("guest-view");
+const guestList = document.getElementById("guest-list");
+const addEntryButton = document.getElementById("add-entry");
+const removeEntryButton = document.getElementById("remove-entry");
+
+// Enable visual elements.
+guestList.setAttribute("hidden", true);
+addEntryButton.removeAttribute("hidden");
+removeEntryButton.removeAttribute("hidden");
+
+function updateGuestList() {
+ guestList.value = guestView.childNodes.map((node) => node.value).join(",");
+}
+
+addEntry.addEventListener("click", () => {
+ let i = guestView.childNodes.length;
+ let elem = document.createElement("input");
+ elem.type = "text";
+ elem.name = `guest-${i}`;
+ guestView.appendChild(elem);
+
+ elem.addEventListener("input", updateGuestList);
+});
+removeEntry.addEventListener("click", () => {
+ if (guestView.lastChild) {
+ guestView.lastChild.remove();
+ }
+ updateGuestList();
+});