diff --git a/tagAutocomplete.js b/tagAutocomplete.js index 82fed8f..bfac10a 100644 --- a/tagAutocomplete.js +++ b/tagAutocomplete.js @@ -176,20 +176,29 @@ function insertTextAtCursor(text, tagword) { previousTags = tags; } -const colors_dark = ["lightblue", "indianred", "unused", "violet", "lightgreen", "orange"]; -const colors_light = ["dodgerblue", "firebrick", "unused", "darkorchid", "darkgreen", "darkorange" ] function addResultsToList(results, tagword) { let resultsList = gradioApp().querySelector('#autocompleteResultsList'); resultsList.innerHTML = ""; - let colors = gradioApp().querySelector('.dark') ? colors_dark : colors_light; + // Find right colors from config + let tagFileName = acConfig.tagFile.split(".")[0]; + let tagColors = acConfig.colors; + //let colorIndex = Object.keys(tagColors).findIndex(key => key === tagFileName); + //let colorValues = Object.values(tagColors)[colorIndex]; + + let mode = gradioApp().querySelector('.dark') ? 0 : 1; for (let i = 0; i < results.length; i++) { let result = results[i]; let li = document.createElement("li"); li.innerHTML = result[0]; - li.style = `color: ${colors[result[1]]};`; + + // Set the color of the tag + let tagType = result[1]; + li.style = `color: ${tagColors[tagFileName][tagType][mode]};`; + // Add listener li.addEventListener("click", function() { insertTextAtCursor(result[0], tagword); }); + // Add element to list resultsList.appendChild(li); } } diff --git a/tags/config.json b/tags/config.json index 1815412..05d0fcb 100644 --- a/tags/config.json +++ b/tags/config.json @@ -1,5 +1,25 @@ { "tagFile": "danbooru.csv", "maxResults": 5, - "replaceUnderscores": true -} + "replaceUnderscores": true, + "colors": { + "danbooru": { + "0": ["lightblue", "dodgerblue"], + "1": ["indianred", "firebrick"], + "3": ["violet", "darkorchid"], + "4": ["lightgreen", "darkgreen"], + "5": ["orange", "darkorange"] + }, + "e621": { + "-1": ["red", "maroon"], + "0": ["lightblue", "dodgerblue"], + "1": ["gold", "goldenrod"], + "3": ["violet", "darkorchid"], + "4": ["lightgreen", "darkgreen"], + "5": ["tomato", "darksalmon"], + "6": ["red", "maroon"], + "7": ["whitesmoke", "black"], + "8": ["seagreen", "darkseagreen"] + } + } +} \ No newline at end of file