mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-22 14:38:00 +00:00
add ability to submit forms with enter key
This commit is contained in:
parent
7e08e18785
commit
45b0de26c7
|
@ -123,7 +123,6 @@ async function request(method, path, body = null) {
|
|||
|
||||
} else {
|
||||
if (Object.hasOwn(message, "created")) {
|
||||
console.log(message.created)
|
||||
message.created = new Date(message.created);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,18 @@ async function handle_config_change(event) {
|
|||
}
|
||||
|
||||
|
||||
document.querySelector("#name").addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13) {
|
||||
await handle_config_change(event);
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelector("#note").addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13 && event.ctrlKey) {
|
||||
await handle_config_change(event);
|
||||
}
|
||||
});
|
||||
|
||||
for (const elem of elems) {
|
||||
elem.addEventListener("change", handle_config_change);
|
||||
}
|
||||
|
|
|
@ -114,6 +114,14 @@ document.querySelector("#new-ban").addEventListener("click", async (event) => {
|
|||
await ban();
|
||||
});
|
||||
|
||||
for (var elem of document.querySelectorAll("#add-item input")) {
|
||||
elem.addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13) {
|
||||
await ban();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (var row of document.querySelector("fieldset.section table").rows) {
|
||||
if (!row.querySelector(".update-ban")) {
|
||||
continue;
|
||||
|
|
|
@ -126,6 +126,14 @@ document.querySelector("#add-instance").addEventListener("click", async (event)
|
|||
await add_instance();
|
||||
})
|
||||
|
||||
for (var elem of document.querySelectorAll("#add-item input")) {
|
||||
elem.addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13) {
|
||||
await add_instance();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (var row of document.querySelector("#instances").rows) {
|
||||
if (!row.querySelector(".remove a")) {
|
||||
continue;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
async function login(event) {
|
||||
fields = {
|
||||
const fields = {
|
||||
username: document.querySelector("#username"),
|
||||
password: document.querySelector("#password")
|
||||
}
|
||||
|
||||
values = {
|
||||
async function login(event) {
|
||||
const values = {
|
||||
username: fields.username.value.trim(),
|
||||
password: fields.password.value.trim()
|
||||
}
|
||||
|
@ -26,4 +26,17 @@ async function login(event) {
|
|||
}
|
||||
|
||||
|
||||
document.querySelector("#username").addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13) {
|
||||
fields.password.focus();
|
||||
fields.password.select();
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelector("#password").addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13) {
|
||||
await login(event);
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelector(".submit").addEventListener("click", login);
|
||||
|
|
|
@ -113,6 +113,22 @@ document.querySelector("#new-ban").addEventListener("click", async (event) => {
|
|||
await ban();
|
||||
});
|
||||
|
||||
for (var elem of document.querySelectorAll("#add-item input")) {
|
||||
elem.addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13) {
|
||||
await ban();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (var elem of document.querySelectorAll("#add-item textarea")) {
|
||||
elem.addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13 && event.ctrlKey) {
|
||||
await ban();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (var row of document.querySelector("#bans").rows) {
|
||||
if (!row.querySelector(".update-ban")) {
|
||||
continue;
|
||||
|
|
|
@ -76,6 +76,14 @@ document.querySelector("#new-user").addEventListener("click", async (event) => {
|
|||
await add_user();
|
||||
});
|
||||
|
||||
for (var elem of document.querySelectorAll("#add-item input")) {
|
||||
elem.addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13) {
|
||||
await add_user();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (var row of document.querySelector("#users").rows) {
|
||||
if (!row.querySelector(".remove a")) {
|
||||
continue;
|
||||
|
|
|
@ -55,6 +55,12 @@ document.querySelector("#new-item").addEventListener("click", async (event) => {
|
|||
await add_whitelist();
|
||||
});
|
||||
|
||||
document.querySelector("#add-item").addEventListener("keydown", async (event) => {
|
||||
if (event.which === 13) {
|
||||
await add_whitelist();
|
||||
}
|
||||
});
|
||||
|
||||
for (var row of document.querySelector("fieldset.section table").rows) {
|
||||
if (!row.querySelector(".remove a")) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue