Merge branch 'united' into mkultra

This commit is contained in:
vfbd 2022-08-22 21:25:42 -04:00
commit 1e9f0e68a0
3 changed files with 33 additions and 2 deletions

View File

@ -3855,7 +3855,6 @@ def get_message(msg):
emit(
'from_server',
{'cmd': 'showfieldbudget', 'data': {"length": None, "max": None, "field": field}},
broadcast=True
)
return

View File

@ -274,6 +274,17 @@ gensettingstf = [
"default": 0,
"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 =[{

View File

@ -241,8 +241,27 @@ function addSetting(ob) {
if(ob.id == "setadventure"){
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() {
@ -2165,6 +2184,9 @@ function interpolateRGB(color0, color1, t) {
}
function updateInputBudget(inputElement) {
let budgetElement = document.getElementById("setshowbudget");
if (budgetElement && !budgetElement.checked) return;
let data = {"unencoded": inputElement.value, "field": inputElement.id};
if (inputElement.id === "anoteinput") {
@ -2182,7 +2204,6 @@ function registerTokenCounters() {
let span = document.createElement("span");
span.classList.add("input-token-usage");
span.innerText = "?/? Tokens";
el.appendChild(span);
let inputElement = el.querySelector("input, textarea");