diff --git a/static/koboldai.js b/static/koboldai.js index 8e0bef57..46154e1d 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -38,8 +38,8 @@ function disconnect() { function reset_story() { console.log("Resetting story"); var story_area = document.getElementById('Selected Text'); - while (story_area.firstChild) { - story_area.removeChild(story_area.firstChild); + while (story_area.lastChild.id != 'story_prompt') { + story_area.removeChild(story_area.lastChild); } var option_area = document.getElementById("Select Options"); while (option_area.firstChild) { @@ -992,10 +992,13 @@ function update_token_lengths() { } max_chunk = -1; for (item of document.getElementById("Selected Text").childNodes) { - if (item.id != "story_prompt") { - chunk_num = parseInt(item.id.replace("Selected Text Chunk ", "")); - if (chunk_num > max_chunk) { - max_chunk = chunk_num; + console.log(item); + if (item.id != undefined) { + if (item.id != "story_prompt") { + chunk_num = parseInt(item.id.replace("Selected Text Chunk ", "")); + if (chunk_num > max_chunk) { + max_chunk = chunk_num; + } } } } diff --git a/templates/index_new.html b/templates/index_new.html index 27630f78..aae69c18 100644 --- a/templates/index_new.html +++ b/templates/index_new.html @@ -32,7 +32,7 @@ -
+