From c0fb992091a4300e584d22af8272a23dcb6a3a2c Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 24 Oct 2022 12:16:40 -0400 Subject: [PATCH] Fix for world info key tabbing --- aiserver.py | 2 ++ static/koboldai.js | 16 ++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/aiserver.py b/aiserver.py index 78d30eea..8217bbb4 100644 --- a/aiserver.py +++ b/aiserver.py @@ -8483,12 +8483,14 @@ def UI_2_edit_world_info(data): print(data) if data['uid'] < 0: + logger.debug("Creating WI: {}".format(data)) koboldai_vars.worldinfo_v2.add_item(data['title'], data['key'], data['keysecondary'], data['folder'], data['constant'], data['manual_text'], data['comment'], wpp=data['wpp'], use_wpp=data['use_wpp']) emit("delete_new_world_info_entry", {}) else: + logger.debug("Editting WI: {}".format(data)) koboldai_vars.worldinfo_v2.edit_item(data['uid'], data['title'], data['key'], data['keysecondary'], data['folder'], data['constant'], data['manual_text'], diff --git a/static/koboldai.js b/static/koboldai.js index 2e2af335..e9b1a5a1 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1697,14 +1697,10 @@ function process_world_info_entry(data) { function world_info_entry(data) { world_info_data[data.uid] = data; - //delete the existing world info and recreate - var original_focus = null; + //First let's get the id of the element we're on so we can restore it after removing the object + var original_focus = document.activeElement.id; + if (document.getElementById("world_info_"+data.uid)) { - //First let's get the id of the element we're on so we can restore it after removing the object - original_focus = document.activeElement.id; - //console.log("Active ID: "+original_focus); - //console.log(document.activeElement); - //document.getElementById("world_info_"+data.uid).remove(); world_info_card = document.getElementById("world_info_"+data.uid); } else { world_info_card_template = document.getElementById("world_info_"); @@ -2025,7 +2021,7 @@ function world_info_entry(data) { } on_new_wi_item = null; //for some reason we have to wrap this in a timmer - setTimeout(function() {document.getElementById(original_focus).click();document.getElementById(original_focus).focus()}, 0); + setTimeout(function() {document.getElementById(original_focus.replace("-1", data.uid)).click();document.getElementById(original_focus.replace("-1", data.uid)).focus()}, 0); } } @@ -3268,7 +3264,7 @@ function add_tags(tags, data) { text.onblur = function () { this.parentElement.parentElement.parentElement.setAttribute('draggable', 'true'); this.setAttribute('draggable', 'true'); - if (this.textContent != "") { + if (this.textContent.trim() != "") { //console.log(this.textContent); on_new_wi_item = this.id; world_info_data[this.getAttribute('uid')]['key'].push(this.textContent); @@ -3346,7 +3342,7 @@ function add_secondary_tags(tags, data) { text.onblur = function () { this.parentElement.parentElement.parentElement.setAttribute('draggable', 'true'); this.setAttribute('draggable', 'true'); - if (this.textContent != "") { + if (this.textContent.trim() != "") { on_new_wi_item = this.id; world_info_data[this.getAttribute('uid')]['keysecondary'].push(this.textContent); send_world_info(this.getAttribute('uid'));