Make club loading nicer

This commit is contained in:
somebody
2022-10-30 21:34:49 -05:00
parent 53b1695627
commit cdb058e47d
2 changed files with 27 additions and 3 deletions

View File

@@ -4900,6 +4900,7 @@ function updateTitle() {
}
function openClubImport() {
$el("#aidgpromptnum").value = "";
openPopup("aidg-import-popup");
}
@@ -5737,3 +5738,26 @@ function deleteConfirmation(sFormatted, confirmText, denyText, confirmCallback,
openPopup("confirm-delete-dialog");
}
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();
});

View File

@@ -122,10 +122,10 @@
<br/>
<div style="text-align: center;"><a href="https://aetherroom.club/" target="_blank" rel="noopener noreferrer">https://aetherroom.club/</a></div>
<br/>
<input autocomplete="off" class="form-control" type="text" placeholder="Prompt Number (4-digit number at the end of aetherroom.club URL)" id="aidgpromptnum">
<input autocomplete="off" class="form-control focus-on-me" type="text" placeholder="Prompt ID or URL" id="aidgpromptnum">
</div>
<div class="popup_load_cancel">
<button type="button" class="btn btn-primary popup_load_cancel_button" onclick="socket.emit('load_aidg_club', document.getElementById('aidgpromptnum').value);closePopups();">Accept</button>
<button type="button" class="btn btn-primary popup_load_cancel_button" onclick="attemptClubLoad();">Accept</button>
<button type="button" class="btn btn-primary popup_load_cancel_button" onclick="closePopups();">Cancel</button>
</div>
</div>