From 8b2d997a66eac72cc34a94bc32aebbfd6011aa17 Mon Sep 17 00:00:00 2001 From: Concedo Date: Tue, 24 Oct 2023 20:16:11 +0800 Subject: [PATCH] fixed some urlparams issues --- index.html | 87 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/index.html b/index.html index a1ace3b..470749f 100644 --- a/index.html +++ b/index.html @@ -3220,7 +3220,6 @@ var synchro_polled_response = null; var synchro_pending_stream = ""; //used for token pseduo streaming for kobold api only var waiting_for_autosummary = false; - var filter_enabled = true; var italics_regex = new RegExp(/\*(\S[^*]+\S)\*/g); //the fallback regex var temp_scenario = null; var last_token_budget = ""; //to display token limits @@ -3623,6 +3622,8 @@ connect_custom_endpoint(); document.getElementById("lastreq").innerHTML = document.getElementById("lastreq2").innerHTML = `You're using Kobold Lite Embedded.`; + + read_url_params_data(); } else { @@ -3657,46 +3658,12 @@ document.getElementById("connectstatus").classList.add("color_green"); render_gametext(false); - //read the url params, and autoload a shared story if found - const foundStory = urlParams.get('s'); - const foundScenario = urlParams.get('scenario'); - const foundChub = urlParams.get('chub'); - const nofiltermode = urlParams.get('nofilter'); - if (nofiltermode) { - filter_enabled = false; - console.log("Safety filter is off. Use at your own risk."); - } - if (foundStory && foundStory != "") { - let safe_to_overwrite = (gametext_arr.length == 0 && current_memory == "" && current_anote == "" && current_wi.length == 0 && redo_arr.length == 0); - if (localsettings.persist_session && !safe_to_overwrite) { - import_compressed_story_prompt_overwrite(foundStory); - } else { - import_compressed_story(foundStory,false); - } - //purge url params - window.history.replaceState(null, null, window.location.pathname); - } else if (foundScenario && foundScenario != "") { - display_scenarios(); - document.getElementById("scenariosearch").value = escapeHtml(foundScenario); - scenario_search(); - const found = scenario_db.find(m => m.title.toLowerCase() == foundScenario.trim().toLowerCase()); - if (found !== undefined) { - temp_scenario = found; - preview_temp_scenario(); - } - //purge url params - window.history.replaceState(null, null, window.location.pathname); - } else if (foundChub && foundChub != "") { - display_scenarios(); - get_chubai_scenario(foundChub); - //purge url params - window.history.replaceState(null, null, window.location.pathname); - } - else { - if (popup_aiselect) { - display_models(); - } + read_url_params_data(); + + if (popup_aiselect) { + display_models(); } + } else { msgbox("Failed to connect to KAI Horde!\nPlease check your network connection."); @@ -3723,6 +3690,41 @@ } } + function read_url_params_data() + { + //read the url params, and autoload a shared story if found + const foundStory = urlParams.get('s'); + const foundScenario = urlParams.get('scenario'); + const foundChub = urlParams.get('chub'); + + if (foundStory && foundStory != "") { + let safe_to_overwrite = (gametext_arr.length == 0 && current_memory == "" && current_anote == "" && current_wi.length == 0 && redo_arr.length == 0); + if (localsettings.persist_session && !safe_to_overwrite) { + import_compressed_story_prompt_overwrite(foundStory); + } else { + import_compressed_story(foundStory, false); + } + //purge url params + window.history.replaceState(null, null, window.location.pathname); + } else if (foundScenario && foundScenario != "") { + display_scenarios(); + document.getElementById("scenariosearch").value = escapeHtml(foundScenario); + scenario_search(); + const found = scenario_db.find(m => m.title.toLowerCase() == foundScenario.trim().toLowerCase()); + if (found !== undefined) { + temp_scenario = found; + preview_temp_scenario(); + } + //purge url params + window.history.replaceState(null, null, window.location.pathname); + } else if (foundChub && foundChub != "") { + display_scenarios(); + get_chubai_scenario(foundChub); + //purge url params + window.history.replaceState(null, null, window.location.pathname); + } + } + var image_models_fetched = false; function fetch_image_models(onDoneCallback) { @@ -8576,7 +8578,7 @@ sentence = localsettings.image_styles + " " + sentence; } - if (filter_enabled && localsettings.generate_images_mode==1) { + if (localsettings.generate_images_mode==1) { sentence = sanitize_horde_image_prompt(sentence); } @@ -9972,6 +9974,7 @@ let foundimg = ""; if(curr.msg && curr.msg!="") { + curr.msg = curr.msg.replace(italics_regex,"$1"); //convert the msg into images curr.msg = curr.msg.replace(/\[<\|p\|.+?\|p\|>\]/g, function (m) { // m here means the whole matched string @@ -9986,7 +9989,7 @@ return inner; }); curr.msg = curr.msg.replace(/\[<\|.+?\|>\]/g, ""); //remove normal comments too - curr.msg = curr.msg.replace(italics_regex,"$1"); + }