diff --git a/.gitignore b/.gitignore index 9a70a260..46718789 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ userscripts !userscripts/api_documentation.* softprompts models +functional_models !models/models go here.txt Uninstall flask_session diff --git a/Install Horde Bridge.bat b/Install Horde Bridge.bat deleted file mode 100644 index c1d48fcf..00000000 --- a/Install Horde Bridge.bat +++ /dev/null @@ -1,41 +0,0 @@ -@echo off -cd /D %~dp0 -TITLE KoboldAI - Installing Horde Bridge -SET /P M=nul -subst K: miniconda3 >nul -SET TEMP=K:\ -SET TMP=K:\ -call K:\python\condabin\activate -git clone https://github.com/db0/KoboldAI-Horde-Bridge KoboldAI-Horde -python -m venv KoboldAI-Horde\venv -KoboldAI-Horde\venv\scripts\pip install -r KoboldAI-Horde\requirements.txt -cmd /k - -:drivemap_B -ECHO Runtime launching in B: drive mode -subst /D B: >nul -subst B: miniconda3 >nul -SET TEMP=B:\ -SET TMP=B:\ -call B:\python\condabin\activate -git clone https://github.com/db0/KoboldAI-Horde-Bridge KoboldAI-Horde -python -m venv KoboldAI-Horde\venv -KoboldAI-Horde\venv\scripts\pip install -r KoboldAI-Horde\requirements.txt -cmd /k diff --git a/readme.md b/README.md similarity index 98% rename from readme.md rename to README.md index 413242d5..20a1957a 100644 --- a/readme.md +++ b/README.md @@ -105,7 +105,7 @@ KoboldAI has a large number of dependencies you will need to install on your com ### Downloading the latest version of KoboldAI -KoboldAI is a rolling release on our github, the code you see is also the game. You can the software by clicking on the green Code button at the top of the page and clicking Download ZIP. +KoboldAI is a rolling release on our github, the code you see is also the game. You can download the software by clicking on the green Code button at the top of the page and clicking Download ZIP, or use the `git clone` command instead. Then, on Windows you need to you run install_requirements.bat (using admin mode is recommanded to avoid errors), and once it's done, or if you're on Linux, either play.bat/sh or remote-play.bat/sh to run it. The easiest way for Windows users is to use the [offline installer](https://sourceforge.net/projects/koboldai/files/latest/download) below. @@ -228,4 +228,4 @@ Did we miss your contribution? Feel free to issue a commit adding your name to t KoboldAI is licensed with a AGPL license, in short this means that it can be used by anyone for any purpose. However, if you decide to make a publicly available instance your users are entitled to a copy of the source code including all modifications that you have made (which needs to be available trough an interface such as a button on your website), you may also not distribute this project in a form that does not contain the source code (Such as compiling / encrypting the code and distributing this version without also distributing the source code that includes the changes that you made. You are allowed to distribute this in a closed form if you also provide a separate archive with the source code.). -umamba.exe is bundled for convenience because we observed that many of our users had trouble with command line download methods, it is not part of our project and does not fall under the AGPL license. It is licensed under the BSD-3-Clause license. Other files with differing licenses will have a reference or embedded version of this license within the file. It has been sourced from https://anaconda.org/conda-forge/micromamba/files and its source code can be found here : https://github.com/mamba-org/mamba/tree/master/micromamba \ No newline at end of file +umamba.exe is bundled for convenience because we observed that many of our users had trouble with command line download methods, it is not part of our project and does not fall under the AGPL license. It is licensed under the BSD-3-Clause license. Other files with differing licenses will have a reference or embedded version of this license within the file. It has been sourced from https://anaconda.org/conda-forge/micromamba/files and its source code can be found here : https://github.com/mamba-org/mamba/tree/master/micromamba diff --git a/aiserver.py b/aiserver.py index d35b917b..a6337dc9 100644 --- a/aiserver.py +++ b/aiserver.py @@ -9532,7 +9532,7 @@ def UI_2_generate_image_from_story(data): koboldai_vars.generating_image = True eventlet.sleep(0) - art_guide = '{}'.format(koboldai_vars.img_gen_art_guide) + art_guide = str(koboldai_vars.img_gen_art_guide) if 'action_id' in data and (int(data['action_id']) in koboldai_vars.actions.actions or int(data['action_id']) == -1): action_id = int(data['action_id']) @@ -9566,13 +9566,21 @@ def UI_2_generate_image_from_story(data): max_length = args.max_summary_length - len(koboldai_vars.summary_tokenizer.encode(art_guide)) keys = [summarize(text, max_length=max_length)] - logger.debug("Text from summarizer: {}".format(keys[0])) - prompt = ", ".join(keys) + logger.debug("Text from summarizer: {}".format(prompt)) + + if art_guide: + if '<|>' in art_guide: + full_prompt = art_guide.replace('<|>', prompt) + else: + full_prompt = f"{prompt}, {art_guide}" + else: + full_prompt = prompt + generate_story_image( - ", ".join([part for part in [prompt, art_guide] if part]), + full_prompt, file_prefix=f"action_{action_id}", - display_prompt=prompt, + display_prompt=full_prompt, log_data={"actionId": action_id}, ) diff --git a/colab/GPU.ipynb b/colab/GPU.ipynb index 8c76b5ed..203f53ba 100644 --- a/colab/GPU.ipynb +++ b/colab/GPU.ipynb @@ -6,7 +6,6 @@ "name": "ColabKobold GPU", "private_outputs": true, "provenance": [], - "collapsed_sections": [], "include_colab_link": true }, "kernelspec": { @@ -40,7 +39,23 @@ "\n", "For more information about KoboldAI check our our Github readme : https://github.com/KoboldAI/KoboldAI-Client/blob/main/readme.md\n", "\n", - "For the larger AI models (That are typically more coherent) check out our **[TPU edition](https://colab.research.google.com/github/KoboldAI/KoboldAI-Client/blob/main/colab/TPU.ipynb)**!" + "For the larger AI models (That are typically more coherent) check out our **[TPU edition](https://colab.research.google.com/github/KoboldAI/KoboldAI-Client/blob/main/colab/TPU.ipynb)**!\n", + "\n", + "---\n", + "## How to load KoboldAI: Everything you need to know\n", + "1. On a phone? First put your browser in desktop mode because of a Google Colab bug. Otherwise nothing will happen when you click the play button. Then tap the play button next to \"<-- Tap This if you play on Mobile\", you will see an audio player. Keep the audio player playing so Colab does not get shut down in the background.\n", + "2. Select the desired model, you will find a description of all the available models further down the page.\n", + "3. Click the play button next to \"<-- Select your model below and then click this to start KoboldAI\".\n", + "4. Got a message saying no accelerator is available? Click cancel, and try again in a few minutes. If you do not manage to get a session when you frequently try again try at a different time of day, colab can be busy or your priority may have been lowered by frequent usage.\n", + "5. After everything is done loading you will get a link that you can use to open KoboldAI. In case of Localtunnel you will also be warned that some people are abusing Localtunnel for phishing, once you acknowledge this warning you will be taken to KoboldAI's interface. If you picked Cloudflare and get a 1033 error refresh the error page after waiting one minute.\n", + "\n", + "---\n", + "\n", + "Further down the page you can find descriptions of the models, and tips to get the most out of your Google Colab experience.\n", + "\n", + "Make sure to keep this page open while you are using KoboldAI, and check back regularly to see if you got a Captcha. Failure to complete the captcha's in time can result in termination of your session or a lower priority towards the TPUs.\n", + "\n", + "Firefox users need to disable the enhanced tracking protection or use a different browser in order to be able to use Google Colab without errors (This is not something we can do anything about, the cookie blocker breaks the Google Drive integration because it uses different domains)." ] }, { @@ -67,23 +82,55 @@ "#@title <-- Select your model below and then click this to start KoboldAI\n", "#@markdown You can find a description of the models below along with instructions on how to start KoboldAI.\n", "\n", - "Model = \"Nerys 2.7B\" #@param [\"Nerys 2.7B\", \"AID 2.7B\", \"Erebus 2.7B\", \"Janeway 2.7B\", \"Picard 2.7B\", \"Horni LN 2.7B\", \"Horni 2.7B\", \"Shinen 2.7B\", \"OPT 2.7B\", \"Fairseq Dense 2.7B\", \"Neo 2.7B\"] {allow-input: true}\n", + "Model = \"Nerys V2 6B\" #@param [\"Nerys V2 6B\", \"Erebus 6B\", \"Skein 6B\", \"Janeway 6B\", \"Adventure 6B\", \"Lit V2 6B\", \"Lit 6B\", \"Shinen 6B\", \"Nerys 2.7B\", \"AID 2.7B\", \"Erebus 2.7B\", \"Janeway 2.7B\", \"Picard 2.7B\", \"Horni LN 2.7B\", \"Horni 2.7B\", \"Shinen 2.7B\", \"OPT 2.7B\", \"Fairseq Dense 2.7B\", \"Neo 2.7B\"] {allow-input: true}\n", "Version = \"Official\" #@param [\"Official\", \"United\"] {allow-input: true}\n", "Provider = \"Localtunnel\" #@param [\"Localtunnel\", \"Cloudflare\"]\n", - "use_google_drive = True #@param {type:\"boolean\"}\n", + "use_google_drive = True #@param {type:\"boolean\"}\n", "\n", "!nvidia-smi\n", "from google.colab import drive\n", "if use_google_drive:\n", - " drive.mount('/content/drive/')\n", - "else:\n", - " import os\n", - " if not os.path.exists(\"/content/drive\"):\n", - " os.mkdir(\"/content/drive\")\n", - " if not os.path.exists(\"/content/drive/MyDrive/\"):\n", - " os.mkdir(\"/content/drive/MyDrive/\")\n", + " drive.mount('/content/drive/')\n", + "else:\n", + " import os\n", + " if not os.path.exists(\"/content/drive\"):\n", + " os.mkdir(\"/content/drive\")\n", + " if not os.path.exists(\"/content/drive/MyDrive/\"):\n", + " os.mkdir(\"/content/drive/MyDrive/\")\n", "\n", - "if Model == \"Nerys 2.7B\":\n", + "if Model == \"Nerys V2 6B\":\n", + " Model = \"KoboldAI/OPT-6B-nerys-v2\"\n", + " path = \"\"\n", + " download = \"\"\n", + "elif Model == \"Erebus 6B\":\n", + " Model = \"KoboldAI/OPT-6.7B-Erebus\"\n", + " path = \"\"\n", + " download = \"\"\n", + "elif Model == \"Skein 6B\":\n", + " Model = \"KoboldAI/GPT-J-6B-Skein\"\n", + " path = \"\"\n", + " download = \"\"\n", + "elif Model == \"Janeway 6B\":\n", + " Model = \"KoboldAI/GPT-J-6B-Janeway\"\n", + " path = \"\"\n", + " download = \"\"\n", + "elif Model == \"Adventure 6B\":\n", + " Model = \"KoboldAI/GPT-J-6B-Adventure\"\n", + " path = \"\"\n", + " download = \"\"\n", + "elif Model == \"Lit V2 6B\":\n", + " Model = \"hakurei/litv2-6B-rev3\"\n", + " path = \"\"\n", + " download = \"\"\n", + "elif Model == \"Lit 6B\":\n", + " Model = \"hakurei/lit-6B\"\n", + " path = \"\"\n", + " download = \"\"\n", + "elif Model == \"Shinen 6B\":\n", + " Model = \"KoboldAI/GPT-J-6B-Shinen\"\n", + " path = \"\"\n", + " download = \"\"\n", + "elif Model == \"Nerys 2.7B\":\n", " Model = \"KoboldAI/fairseq-dense-2.7B-Nerys\"\n", " path = \"\"\n", " download = \"\"\n", diff --git a/colabkobold.sh b/colabkobold.sh index 4c41675a..799a6d9c 100644 --- a/colabkobold.sh +++ b/colabkobold.sh @@ -98,6 +98,9 @@ mkdir /content/drive/MyDrive/KoboldAI/models/ mkdir /content/drive/MyDrive/KoboldAI/settings/ mkdir /content/drive/MyDrive/KoboldAI/softprompts/ mkdir /content/drive/MyDrive/KoboldAI/userscripts/ +mkdir /content/drive/MyDrive/KoboldAI/presets/ +mkdir /content/drive/MyDrive/KoboldAI/themes/ + if [ "$init" == "drive" ]; then echo Google Drive folders created. exit 0 @@ -136,11 +139,15 @@ if [ "$init" != "skip" ]; then git reset --hard origin/$(git_default_branch) fi + git submodule update --init --recursive + cd /content/KoboldAI-Client cp -rn stories/* /content/drive/MyDrive/KoboldAI/stories/ cp -rn userscripts/* /content/drive/MyDrive/KoboldAI/userscripts/ cp -rn softprompts/* /content/drive/MyDrive/KoboldAI/softprompts/ + cp -rn presets/* /content/drive/MyDrive/KoboldAI/presets/ + cp -rn themes/* /content/drive/MyDrive/KoboldAI/themes/ rm stories rm -rf stories/ rm userscripts @@ -149,11 +156,17 @@ if [ "$init" != "skip" ]; then rm -rf softprompts/ rm models rm -rf models/ + rm presets + rm -rf presets/ + rm themes + rm -rf themes/ ln -s /content/drive/MyDrive/KoboldAI/stories/ stories ln -s /content/drive/MyDrive/KoboldAI/settings/ settings ln -s /content/drive/MyDrive/KoboldAI/softprompts/ softprompts ln -s /content/drive/MyDrive/KoboldAI/userscripts/ userscripts ln -s /content/drive/MyDrive/KoboldAI/models/ models + ln -s /content/drive/MyDrive/KoboldAI/presets/ presets + ln -s /content/drive/MyDrive/KoboldAI/themes/ themes if [ -n "${COLAB_TPU_ADDR+set}" ]; then pip install -r requirements_mtj.txt diff --git a/docker-standalone/docker-helper.sh b/docker-standalone/docker-helper.sh index 30107e8a..5d738e6c 100755 --- a/docker-standalone/docker-helper.sh +++ b/docker-standalone/docker-helper.sh @@ -1,7 +1,7 @@ #!/bin/bash cd /opt/koboldai -git pull -#./install_requirements.sh cuda + +git pull --recurse-submodules && ./install_requirements.sh cuda if [[ ! -v KOBOLDAI_DATADIR ]];then mkdir /content diff --git a/gensettings.py b/gensettings.py index 1e6f94fa..214d2f45 100644 --- a/gensettings.py +++ b/gensettings.py @@ -613,7 +613,7 @@ gensettingstf = [ "label": "Art Guide", "id": "img_gen_art_guide", "default": "", - "tooltip": "The art guide sent with image gen requests. \nDefault: fantasy illustration, artstation, by jason felix by steve argyle by tyler jacobson by peter mohrbacher, cinematic lighting", + "tooltip": "The art guide sent with image gen requests. <|> (optional) is replaced with the story summary, otherwise the art guide is appended to the summary. \nDefault: masterpiece, digital painting, <|>, dramatic lighting, highly detailed, trending", "menu_path": "Interface", "sub_path": "Images", "classname": "user", diff --git a/koboldai_settings.py b/koboldai_settings.py index dd19b77e..6d8049cc 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1160,7 +1160,7 @@ class user_settings(settings): self.show_budget = False self.ui_level = 2 self.img_gen_api_url = "http://127.0.0.1:7860" - self.img_gen_art_guide = "digital painting, dramatic lighting, highly detailed, trending" + self.img_gen_art_guide = "masterpiece, digital painting, <|>, dramatic lighting, highly detailed, trending" self.img_gen_negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name" self.img_gen_steps = 30 self.img_gen_cfg_scale = 7.0 diff --git a/static/koboldai.css b/static/koboldai.css index fd0796b5..750a82e4 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -16,10 +16,12 @@ input[type='range'] { overflow: hidden; border-color: var(--setting_background); - width: 100%; + width: calc(100% - 10px); -webkit-appearance: none; background-color: var(--rangeslider_background_color); border-radius: 16px; + margin-left: 5px; + margin-right: 5px; } input[type='range']::-webkit-slider-runnable-track { @@ -179,9 +181,12 @@ border-top-right-radius: var(--tabs_rounding); display: flex; flex-direction: row; flex-wrap: wrap; - width: 100%; } +#Images { + padding-left: 10px; + padding-right: 10px; +} .dynamic-setting-container { background-color: var(--setting_background); @@ -213,6 +218,7 @@ border-top-right-radius: var(--tabs_rounding); border-radius: var(--radius_settings_background); padding: 2px; margin: 2px; + width: calc(50% - 4px); } .setting_container_sp { @@ -229,6 +235,11 @@ border-top-right-radius: var(--tabs_rounding); margin: 2px; } +#biasing { + margin-left: 5px; + margin-right: 5px; +} + .setting_container.var_sync_alt_system_alt_gen[system_alt_gen="true"] { display: none; } @@ -250,6 +261,7 @@ border-top-right-radius: var(--tabs_rounding); border-radius: var(--radius_settings_background); padding: 2px; margin-top: 5px; + flex-grow: 1; } #story_menu_author .setting_tile_area{ @@ -269,6 +281,7 @@ border-top-right-radius: var(--tabs_rounding); border-radius: var(--radius_settings_background); padding: 2px; margin: 2px; + width: calc(50% - 4px); } .setting_container_single .setting_item{ font-size: calc(0.93em + var(--font_size_adjustment)); @@ -287,6 +300,7 @@ border-top-right-radius: var(--tabs_rounding); border-radius: var(--radius_settings_background); padding: 1px; margin: 2px; + width: calc(100% - 8px); } .setting_container_single_wide .setting_item{ font-size: calc(0.93em + var(--font_size_adjustment)); @@ -343,6 +357,10 @@ border-top-right-radius: var(--tabs_rounding); overflow: hidden; } +.setting_item .toggle { + margin-left: 5px; +} + .setting_item_input { width:95%; } @@ -453,7 +471,7 @@ border-top-right-radius: var(--tabs_rounding); .SideMenu .flyout_menu_contents { overflow-x: hidden; overflow-y: auto; - height: calc(100vh - 40px); + height: calc(100vh - 34px); } .settings_footer { @@ -544,6 +562,9 @@ border-top-right-radius: var(--tabs_rounding); border-radius: var(--radius_settings_button); border-style:solid; height: 35px; + display: inline-flex; + align-items: center; + justify-content: center; } .settings_button > .material-icons-outlined { @@ -551,13 +572,6 @@ border-top-right-radius: var(--tabs_rounding); top: 2px; } - -.settings_button > .button_label { - position: relative; - bottom: 3px; - right: 4px; -} - .settings_button > .material-icons-outlined { position: relative; top: 1px; @@ -565,8 +579,7 @@ border-top-right-radius: var(--tabs_rounding); } .Model_Info .settings_button { - transform: translateY(7%); - margin: -5px; + margin: 5px; } #import_story_button { @@ -752,7 +765,7 @@ border-top-right-radius: var(--tabs_rounding); border: 2px solid var(--palette_card_text); border-radius: var(--radius_palette_card); box-shadow: var(--palette_card_shadow); - margin: 5px; + margin-top: 5px; padding: 5px 0 10px 0; background: var(--palette_card_background); color: var(--palette_card_text); @@ -1110,12 +1123,20 @@ td.server_vars { .world_info_item_type { /* Workaround for Firefox bug: https://stackoverflow.com/a/42283543 */ padding: 1px; + padding-bottom: 0px; + display: inline-block; + height: 2.8ex; + cursor: text; outline: none; border-bottom: 1px solid gray; transition: color 200ms, border-bottom-color 200ms; } +.world_info_item_type::before { + opacity: 0.3 !important; +} + .world_info_item_type.bad-input { color: rgb(255, 103, 103); border-bottom-color: red; @@ -2461,6 +2482,7 @@ body { opacity: 0.7; font-size: small; float: right; + padding-right: 10px; } .debug-dump-log { @@ -2605,6 +2627,13 @@ body { } /* Substitutions */ +#Substitutions { + margin-left: 10px; + margin-right: 10px; + justify-content: center; + width: auto; +} + #Substitutions > .help_text > .helpicon { position: relative; margin-left: 1px; @@ -2731,6 +2760,7 @@ body { display: flex; justify-content: center; align-items: center; + flex-direction: column; background-color: rgba(0, 0, 0, 0.7); @@ -3187,6 +3217,11 @@ button.disabled { padding: 5px 7px 5px 7px; } +textarea.fullwidth { + border-style: solid; + resize: vertical; +} + .rawtext { white-space: pre-wrap; } @@ -3489,8 +3524,19 @@ input[type='range'] { select { outline: none; + border: 1px solid; } +@-moz-document url-prefix() { + select, .presets { + padding-left: 5px; /* Add padding to the left side of the select element */ + } + select { + padding-top: 0; + } +} + + [system_experimental_features="false"] { display: none; } diff --git a/static/koboldai.js b/static/koboldai.js index 7e0817db..0742c70f 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2993,66 +2993,74 @@ function toggle_adventure_mode(button) { } function select_game_text(event) { - if ((event == null) || (event.code == 'ArrowRight') || (event.code == 'ArrowLeft') || (event.code == 'ArrowDown') || (event.code == 'ArrowUp')) { - let new_selected_game_chunk = null; - if (document.selection) { - if (document.selection.createRange().parentElement().id == 'story_prompt') { - new_selected_game_chunk = document.selection.createRange().parentElement(); - } else if (document.selection.createRange().parentElement().id == 'gamescreen') { + if (!((event === null) || ["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp"].includes(event.code))) return; + + let anchorNode = window.getSelection().anchorNode; + let new_selected_game_chunk = null; + + if (document.selection) { + if (document.selection.createRange().parentElement().id == 'story_prompt') { + new_selected_game_chunk = document.selection.createRange().parentElement(); + } else if (document.selection.createRange().parentElement().id == 'gamescreen') { + new_selected_game_chunk = null; + //console.log("Do nothing"); + } else { + new_selected_game_chunk = document.selection.createRange().parentElement().parentElement(); + } + } else if (anchorNode != null && anchorNode.tagName === "SPAN") { + // If clicking to the right of an action, the event target is actually + // the whole of gametext, and the anchorNode is a child span of an + // action rather than a text node. + new_selected_game_chunk = anchorNode.parentNode; + } else if (anchorNode != null ) { + if(anchorNode.parentNode) { + if (anchorNode.parentNode.id == 'story_prompt') { + new_selected_game_chunk = anchorNode.parentNode; + } else if (anchorNode.parentNode.id == "gamescreen") { new_selected_game_chunk = null; //console.log("Do nothing"); } else { - new_selected_game_chunk = document.selection.createRange().parentElement().parentElement(); + new_selected_game_chunk = anchorNode.parentNode.parentNode; } - } else if (window.getSelection().anchorNode != null ) { - if(window.getSelection().anchorNode.parentNode) { - if (window.getSelection().anchorNode.parentNode.id == 'story_prompt') { - new_selected_game_chunk = window.getSelection().anchorNode.parentNode; - } else if (window.getSelection().anchorNode.parentNode.id == "gamescreen") { - new_selected_game_chunk = null; - //console.log("Do nothing"); - } else { - new_selected_game_chunk = window.getSelection().anchorNode.parentNode.parentNode; - } + } else { + new_selected_game_chunk = null; + } + } + + //if we've moved to a new game chunk we need to save the old chunk + if (((new_selected_game_chunk != selected_game_chunk) && (selected_game_chunk != null)) || (document.activeElement != document.getElementById("Selected Text"))) { + if ((selected_game_chunk != null) && (selected_game_chunk.innerText != selected_game_chunk.original_text) && (selected_game_chunk != document.getElementById("welcome_text"))) { + if (selected_game_chunk.id == 'story_prompt') { + edit_game_text(-1); } else { - new_selected_game_chunk = null; + edit_game_text(parseInt(selected_game_chunk.getAttribute("chunk"))); } } - //if we've moved to a new game chunk we need to save the old chunk - if (((new_selected_game_chunk != selected_game_chunk) && (selected_game_chunk != null)) || (document.activeElement != document.getElementById("Selected Text"))) { - if ((selected_game_chunk != null) && (selected_game_chunk.innerText != selected_game_chunk.original_text) && (selected_game_chunk != document.getElementById("welcome_text"))) { - if (selected_game_chunk.id == 'story_prompt') { - edit_game_text(-1); - } else { - edit_game_text(parseInt(selected_game_chunk.getAttribute("chunk"))); - } + } + + //Check to see if new selection is a game chunk or something else + if (new_selected_game_chunk == null) { + selected_game_chunk = null; + for (item of document.getElementsByClassName("editing")) { + item.classList.remove("editing"); + } + window.getSelection().removeAllRanges() + } else if (((new_selected_game_chunk.id == "story_prompt") || (new_selected_game_chunk.id.slice(0,20) == "Selected Text Chunk ")) && (document.activeElement.isContentEditable)) { + if (new_selected_game_chunk != selected_game_chunk) { + for (item of document.getElementsByClassName("editing")) { + item.classList.remove("editing"); } + selected_game_chunk = new_selected_game_chunk; + selected_game_chunk.classList.add("editing"); + update_story_picture(selected_game_chunk.getAttribute("chunk")); } - //Check to see if new selection is a game chunk or something else - if (new_selected_game_chunk == null) { - selected_game_chunk = null; - for (item of document.getElementsByClassName("editing")) { - item.classList.remove("editing"); - } - window.getSelection().removeAllRanges() - } else if (((new_selected_game_chunk.id == "story_prompt") || (new_selected_game_chunk.id.slice(0,20) == "Selected Text Chunk ")) && (document.activeElement.isContentEditable)) { - if (new_selected_game_chunk != selected_game_chunk) { - for (item of document.getElementsByClassName("editing")) { - item.classList.remove("editing"); - } - selected_game_chunk = new_selected_game_chunk; - selected_game_chunk.classList.add("editing"); - update_story_picture(selected_game_chunk.getAttribute("chunk")); - } - - } else { - selected_game_chunk = null; - for (item of document.getElementsByClassName("editing")) { - item.classList.remove("editing"); - } - window.getSelection().removeAllRanges() + } else { + selected_game_chunk = null; + for (item of document.getElementsByClassName("editing")) { + item.classList.remove("editing"); } + window.getSelection().removeAllRanges() } } diff --git a/templates/popups.html b/templates/popups.html index a5d4e865..b8c9e636 100644 --- a/templates/popups.html +++ b/templates/popups.html @@ -173,7 +173,7 @@ - +