From cdb058e47deb0266a4df7ea13cbc7748d7ae71ff Mon Sep 17 00:00:00 2001 From: somebody Date: Sun, 30 Oct 2022 21:34:49 -0500 Subject: [PATCH] Make club loading nicer --- static/koboldai.js | 26 +++++++++++++++++++++++++- templates/popups.html | 4 ++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/static/koboldai.js b/static/koboldai.js index f6dbbdf0..f7d5f1d5 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -4900,6 +4900,7 @@ function updateTitle() { } function openClubImport() { + $el("#aidgpromptnum").value = ""; openPopup("aidg-import-popup"); } @@ -5736,4 +5737,27 @@ function deleteConfirmation(sFormatted, confirmText, denyText, confirmCallback, } openPopup("confirm-delete-dialog"); -} \ No newline at end of file +} + +function attemptClubLoad() { + const input = $el("#aidgpromptnum"); + let val = input.value; + if (!/^\d+$/.test(val)) { + // Not an id, is it a full URL? + const matches = val.match(/aetherroom\.club\/([0-9]+)/) + if (!matches) { + reportError("Malformed club import", "That doesn't look like a valid club URL or ID. Please check your input and try again."); + return; + } + val = matches[1]; + } + socket.emit("load_aidg_club", val); + closePopups(); +} + + +$el("#aidgpromptnum").addEventListener("keydown", function(event) { + if (event.key !== "Enter") return; + attemptClubLoad(); + event.preventDefault(); +}); \ No newline at end of file diff --git a/templates/popups.html b/templates/popups.html index 0598c665..46004b33 100644 --- a/templates/popups.html +++ b/templates/popups.html @@ -122,10 +122,10 @@
https://aetherroom.club/

- +