From e00199cf061d59356cf23c20d71b8e2cf12be7d8 Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Sat, 28 Jan 2023 22:36:16 +0100 Subject: [PATCH] Move potentially shared vars to separate file to ensure that they exist when other parts reference them --- javascript/_globals.js | 24 ++++++++++++++++++++++++ javascript/tagAutocomplete.js | 24 ------------------------ 2 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 javascript/_globals.js diff --git a/javascript/_globals.js b/javascript/_globals.js new file mode 100644 index 0000000..c49757e --- /dev/null +++ b/javascript/_globals.js @@ -0,0 +1,24 @@ +var CFG = null; + +var tagBasePath = ""; +var allTags = []; +var translations = new Map(); + +var currentModelHash = ""; +var currentModelName = ""; + +var wildcardFiles = []; +var wildcardExtFiles = []; +var yamlWildcards = []; +var umiPreviousTags = []; +var embeddings = []; +var hypernetworks = []; +var loras = []; +var results = []; +var tagword = ""; +var originalTagword = ""; +var resultCount = 0; + +var selectedTag = null; +var oldSelectedTag = null; +var previousTags = []; \ No newline at end of file diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 062de4c..7473884 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -1,5 +1,3 @@ -var CFG = null; - const styleColors = { "--results-bg": ["#0b0f19", "#ffffff"], "--results-border-color": ["#4b5563", "#e5e7eb"], @@ -85,10 +83,6 @@ const autocompleteCSS = ` } `; -var tagBasePath = ""; -var allTags = []; -var translations = new Map(); - async function loadTags(c) { // Load main tags and aliases if (allTags.length === 0 && c.tagFile && c.tagFile !== "None") { @@ -248,10 +242,6 @@ function createResultsDiv(textArea) { return resultsDiv; } -// The selected tag index. Needs to be up here so hide can access it. -var selectedTag = null; -var previousTags = []; - // Show or hide the results div function isVisible(textArea) { let textAreaId = getTextAreaIdentifier(textArea); @@ -270,8 +260,6 @@ function hideResults(textArea) { selectedTag = null; } -var currentModelHash = ""; -var currentModelName = ""; // Function to check activation criteria function isEnabled() { if (CFG.activeIn.global) { @@ -569,17 +557,6 @@ function updateSelectionStyle(textArea, newIndex, oldIndex) { } } -var wildcardFiles = []; -var wildcardExtFiles = []; -var yamlWildcards = []; -var umiPreviousTags = []; -var embeddings = []; -var hypernetworks = []; -var loras = []; -var results = []; -var tagword = ""; -var originalTagword = ""; -var resultCount = 0; async function autocomplete(textArea, prompt, fixedTag = null) { // Return if the function is deactivated in the UI if (!isEnabled()) return; @@ -1023,7 +1000,6 @@ async function autocomplete(textArea, prompt, fixedTag = null) { addResultsToList(textArea, results, tagword, true); } -var oldSelectedTag = null; function navigateInList(textArea, event) { // Return if the function is deactivated in the UI or the current model is excluded due to white/blacklist settings if (!isEnabled()) return;