From f6e56ad8e6ab2745eb75881ad494dfac6e525989 Mon Sep 17 00:00:00 2001 From: RossAsscends <124905043+RossAscends@users.noreply.github.com> Date: Mon, 20 Mar 2023 17:32:48 +0900 Subject: [PATCH] removed old commented-out code, and console.logs removed code on .swipe_left listened that controlled right_swipe display removed runGenerate force hiding right_swipe during gen ra-mods - added check for swipe button visibility before KB swiping --- public/script.js | 140 ++++------------------------- public/scripts/RossAscends-mods.js | 20 +---- 2 files changed, 17 insertions(+), 143 deletions(-) diff --git a/public/script.js b/public/script.js index 33a8948eb..c4b8eb803 100644 --- a/public/script.js +++ b/public/script.js @@ -393,13 +393,7 @@ async function getStatus() { main_api == "kobold" ? api_server : api_server_textgenerationwebui, main_api: main_api, }), - beforeSend: function () { - if (is_api_button_press) { - //$("#api_loading").css("display", 'inline-block'); - //$("#api_button").css("display", 'none'); - } - //$('#create_button').attr('value','Creating...'); // - }, + beforeSend: function () { }, cache: false, dataType: "json", crossDomain: true, @@ -531,11 +525,7 @@ function printCharacters() { async function getCharacters() { await getGroups(); - - //console.log('getCharacters() -- entered'); - //console.log(characters); var response = await fetch("/getcharacters", { - //RossAscends: changed from const method: "POST", headers: { "Content-Type": "application/json", @@ -547,44 +537,16 @@ async function getCharacters() { }); if (response.ok === true) { var getData = ""; //RossAscends: reset to force array to update to account for deleted character. - var getData = await response.json(); //RossAscends: changed from const - //console.log(getData); - - //var aa = JSON.parse(getData[0]); - - var load_ch_count = Object.getOwnPropertyNames(getData); //RossAscends: change from const to create dynamic character load amounts. - var charCount = load_ch_count.length; - //console.log('/getcharacters -- expecting to load '+charCount+' characters.') + getData = await response.json(); + const load_ch_count = Object.getOwnPropertyNames(getData); for (var i = 0; i < load_ch_count.length; i++) { characters[i] = []; characters[i] = getData[i]; - //console.log('/getcharacters -- loaded character #'+(i+1)+' ('+characters[i].name+')'); } - //RossAscends: updated character sorting to be alphabetical - characters.sort(function (a, b) { - //console.log('sorting characters: '+a.name+' vs '+b.name); - if (a.name < b.name) { - return -1; - } - if (a.name > b.name) { - return 1; - } - return 0; - }); - //console.log(characters); - - //characters.reverse(); - //console.log('/getcharacters -- this_chid -- '+this_chid); if (this_chid != undefined && this_chid != "invalid-safety-id") { $("#avatar_url_pole").val(characters[this_chid].avatar); } - - //console.log('/getcharacters -- sending '+i+' characters to /printcharacters'); printCharacters(); - //console.log(propOwn.length); - //return JSON.parse(getData[0]); - //const getData = await response.json(); - //var getMessage = getData.results[0].text; } } @@ -677,18 +639,12 @@ async function delBackground(bg) { }), }); if (response.ok === true) { - //const getData = await response.json(); - //background = getData; - //var aa = JSON.parse(getData[0]); - //const load_ch_coint = Object.getOwnPropertyNames(getData); + } } function printMessages() { - //console.log(chat); - //console.log('printMessages() -- printing messages for -- '+this_chid+' '+active_character+' '+characters[this_chid]); chat.forEach(function (item, i, arr) { - //console.log('print message calling addOneMessage'); addOneMessage(item); }); } @@ -803,6 +759,7 @@ function addOneMessage(mes, type = "normal") { newMessage.find('.avatar img').on('error', function () { $(this).attr("src", "/img/user-slash-solid.svg"); }); + if (type === 'swipe') { $("#chat").children().filter('[mesid="' + (count_view_mes - 1) + '"]').children('.mes_block').children('.mes_text').html(''); $("#chat").children().filter('[mesid="' + (count_view_mes - 1) + '"]').children('.mes_block').children('.mes_text').append(messageText); @@ -819,19 +776,7 @@ function addOneMessage(mes, type = "normal") { $('#chat .mes').eq(-2).removeClass('last_mes'); $textchat.scrollTop(($textchat[0].scrollHeight)); - - - //console.log(chat[chat.length - 1].["swipes"]); - //console.log(mes); - /* if (mes["swipes"] !== undefined) { - if (mes["swipes"].length - 1 == mes["swipe_id"]) { //this works to detect when next right swipe would generate - $(".swipe_right").css('opacity', '0.7') // but we need it to happen on load, not only when swiping happens. - } else { - $(".swipe_right").css('opacity', '0.3') - }; - } */ hideSwipeButtons(); - //console.log('addonemessage calling showSwipeBtns'); showSwipeButtons(); } @@ -862,7 +807,6 @@ function sendSystemMessage(type, text) { } chat.push(newMessage); - //console.log('sendSystemMessage calls addOneMessage'); addOneMessage(newMessage); is_send_press = false; } @@ -1200,7 +1144,6 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length return; function runGenerate(cycleGenerationPromt = '') { - $(".swipe_right").css("display", "none"); is_send_press = true; generatedPromtCache += cycleGenerationPromt; @@ -1245,19 +1188,14 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length } } mesSend[mesSend.length] = item; - //chatString = chatString+item; + }); } - //finalPromt +=chatString; - //console.log(storyString); - //console.log(encode(characters[this_chid].description+chatString).length); - //console.log(encode(JSON.stringify(characters[this_chid].description+chatString)).length); if (type == 'force_name2') { finalPromt += name2 + ':'; } - //console.log(JSON.stringify(storyString)); - //Send story string + var mesSendString = ''; var mesExmString = ''; @@ -1268,13 +1206,13 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length mesExmString += mesExamplesArray[j]; } for (let j = 0; j < mesSend.length; j++) { - //console.log('compiling messages for prompt'); + mesSendString += mesSend[j]; } } function checkPromtSize() { - //console.log('checking prompt size'); + setPromtString(); let thisPromtContextSize = encode(JSON.stringify(worldInfoString + storyString + mesExmString + mesSendString + anchorTop + anchorBottom + charPersonality + generatedPromtCache + promptBias + extension_prompt)).length + 120; @@ -1802,7 +1740,6 @@ function changeMainAPI() { "novel": { apiSettings: $("#novel_api-settings"), apiConnector: $("#novel_api"), - apiRanges: $("#range_block_novel"), maxContextElem: $("#max_context_block"), amountGenElem: $("#amount_gen_block"), @@ -1819,9 +1756,6 @@ function changeMainAPI() { apiObj.apiSettings.css("display", isCurrentApi ? "block" : "none"); apiObj.apiConnector.css("display", isCurrentApi ? "block" : "none"); apiObj.apiRanges.css("display", isCurrentApi ? "block" : "none"); - //console.log('--- apiObj.apiElem ---'); - //console.log(apiObj.apiElem); - //console.log(apiObj.apiElem.css("display")); if (isCurrentApi && apiName === "kobold") { console.log("enabling SP for kobold"); @@ -1841,7 +1775,7 @@ function changeMainAPI() { //////////////////////////////////////////////////// async function getUserAvatars() { - $("#user_avatar_block").html(""); //RossAscends: necessary to avoid doubling avatars each QuickRefresh. + $("#user_avatar_block").html(""); //RossAscends: necessary to avoid doubling avatars each refresh. $("#user_avatar_block").append('