From d452467818af20478d27a165f54e23b8f6a46a96 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Thu, 20 Apr 2023 23:58:12 +0900 Subject: [PATCH] - escape from edit message now focuses on send_textarea - allow swipes to happen when send_textarea is focused but empty --- public/script.js | 9 +++++---- public/scripts/RossAscends-mods.js | 14 +++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/public/script.js b/public/script.js index 3a6cb7a15..be8782bea 100644 --- a/public/script.js +++ b/public/script.js @@ -3500,8 +3500,8 @@ $(document).ready(function () { } chat[chat.length - 1]['swipe_id']++; //make new slot in array // if message has memory attached - remove it to allow regen - if (chat[chat.length -1].extra && chat[chat.length -1].extra.memory) { - delete chat[chat.length -1].extra.memory; + if (chat[chat.length - 1].extra && chat[chat.length - 1].extra.memory) { + delete chat[chat.length - 1].extra.memory; } //console.log(chat[chat.length-1]['swipes']); if (parseInt(chat[chat.length - 1]['swipe_id']) === chat[chat.length - 1]['swipes'].length) { //if swipe id of last message is the same as the length of the 'swipes' array @@ -5073,12 +5073,13 @@ $(document).ready(function () { $(document).keyup(function (e) { if (e.key === "Escape") { closeMessageEditor(); + $("#send_textarea").focus(); } }); - $("#bg-filter").on("input", function() { + $("#bg-filter").on("input", function () { const filterValue = $(this).val().toLowerCase(); - $("#bg_menu_content > div").each(function() { + $("#bg_menu_content > div").each(function () { const $bgContent = $(this); if ($bgContent.attr("title").toLowerCase().includes(filterValue)) { $bgContent.show(); diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index 6cb852e00..1f6f7870b 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -655,11 +655,23 @@ $("document").ready(function () { } }); + function isInputElementInFocus() { - return $(document.activeElement).is(":input"); + //return $(document.activeElement).is(":input"); + var focused = $(':focus'); + if (focused.is('input') || focused.is('textarea')) { + if (focused.attr('id') === 'send_textarea') { + return false; + } + return true; + } + return false; } + + + //Additional hotkeys CTRL+ENTER and CTRL+UPARROW document.addEventListener("keydown", (event) => { if (event.ctrlKey && event.key == "Enter") {