From eea2bc84624afc5b298c82e2984dbcd35b3f6b2d Mon Sep 17 00:00:00 2001 From: somebody Date: Fri, 30 Sep 2022 18:35:37 -0500 Subject: [PATCH] Update for $el --- static/koboldai.js | 8 ++++---- templates/index_new.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/static/koboldai.js b/static/koboldai.js index 48c991a5..97a12e06 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -97,9 +97,7 @@ const context_menu_actions = [ // {label: "View Token Probabilities", icon: "account_tree", visibilityCondition: "SELECTION", click: view_selection_probabilities}, ]; -// Elements -const titleInput = document.querySelector(".var_sync_story_story_name"); - +function $el(selector) { return document.querySelector(selector); } const map1 = new Map() map1.set('Top K Sampling', 0) @@ -4415,12 +4413,13 @@ function position_context_menu(contextMenu, x, y) { } function updateTitle() { + const titleInput = $el(".var_sync_story_story_name"); if (!titleInput.innerText) return; document.title = `${titleInput.innerText} - KoboldAI Client`; } $(document).ready(function(){ - on_colab = document.getElementById("on_colab").textContent == "true"; + on_colab = $el("#on_colab").textContent == "true"; if (colab_cookies != null) { for (const cookie of Object.keys(colab_cookies)) { @@ -4686,6 +4685,7 @@ $(document).ready(function(){ highlightEl(wiCard); }); + const titleInput = $el(".var_sync_story_story_name"); titleInput.addEventListener("input", updateTitle); titleInput.addEventListener("sync", updateTitle); diff --git a/templates/index_new.html b/templates/index_new.html index 9c413c8a..ebdb21f5 100644 --- a/templates/index_new.html +++ b/templates/index_new.html @@ -22,7 +22,7 @@ - +