Add show budget setting

This commit is contained in:
somebody
2022-08-22 17:25:55 -05:00
parent d7ebd2ae20
commit 95796faf41
2 changed files with 33 additions and 1 deletions

View File

@@ -274,6 +274,17 @@ gensettingstf = [
"default": 0, "default": 0,
"tooltip": "Shows token selection probabilities. Does not work with more than one gens per action." "tooltip": "Shows token selection probabilities. Does not work with more than one gens per action."
}, },
{
"uitype": "toggle",
"unit": "bool",
"label": "Show Field Budget",
"id": "setshowbudget",
"min": 0,
"max": 1,
"step": 1,
"default": 0,
"tooltip": "Shows token usage when typing in relevant text boxes. <b>May lag slower devices.</b>"
},
] ]
gensettingsik =[{ gensettingsik =[{

View File

@@ -241,8 +241,27 @@ function addSetting(ob) {
if(ob.id == "setadventure"){ if(ob.id == "setadventure"){
setadventure($(this).prop('checked')); setadventure($(this).prop('checked'));
} }
}); });
} }
if (ob.id === "setshowbudget") {
$("#setshowbudget").on("change", function () {
for (const el of document.getElementsByClassName("input-token-usage")) {
if (this.checked) {
el.classList.remove("hidden");
} else {
el.classList.add("hidden");
}
}
});
if (!$("#input-token-usage")[0].checked) {
for (const el of document.getElementsByClassName("input-token-usage")) {
el.classList.add("hidden");
}
}
}
} }
function refreshTitle() { function refreshTitle() {
@@ -2165,6 +2184,9 @@ function interpolateRGB(color0, color1, t) {
} }
function updateInputBudget(inputElement) { function updateInputBudget(inputElement) {
let budgetElement = document.getElementById("setshowbudget");
if (budgetElement && !budgetElement.checked) return;
let data = {"unencoded": inputElement.value, "field": inputElement.id}; let data = {"unencoded": inputElement.value, "field": inputElement.id};
if (inputElement.id === "anoteinput") { if (inputElement.id === "anoteinput") {
@@ -2182,7 +2204,6 @@ function registerTokenCounters() {
let span = document.createElement("span"); let span = document.createElement("span");
span.classList.add("input-token-usage"); span.classList.add("input-token-usage");
span.innerText = "?/? Tokens";
el.appendChild(span); el.appendChild(span);
let inputElement = el.querySelector("input, textarea"); let inputElement = el.querySelector("input, textarea");