Out-of-bounds setting values are now shown in red

This commit is contained in:
Gnome Ann 2022-05-28 19:14:26 -04:00
parent 69a28210e9
commit b9c6c0b3bd
3 changed files with 35 additions and 17 deletions

View File

@ -173,6 +173,14 @@ function addSetting(ob) {
window["setting_"+ob.id] = refin; // Is this still needed? window["setting_"+ob.id] = refin; // Is this still needed?
window["label_"+ob.id] = reflb; // Is this still needed? window["label_"+ob.id] = reflb; // Is this still needed?
// Add event function to input // Add event function to input
var updateLabelColor = function () {
var value = (ob.unit === "float" ? parseFloat : parseInt)(reflb.val());
if(value > ob.max || value < ob.min) {
reflb.addClass("setting-value-warning");
} else {
reflb.removeClass("setting-value-warning");
}
}
var send = function () { var send = function () {
sliders_throttle(ob.id, function () { sliders_throttle(ob.id, function () {
socket.send({'cmd': $(refin).attr('id'), 'data': $(reflb).val()}); socket.send({'cmd': $(refin).attr('id'), 'data': $(reflb).val()});
@ -180,11 +188,12 @@ function addSetting(ob) {
} }
refin.on("input", function (event) { refin.on("input", function (event) {
reflb.val(refin.val()); reflb.val(refin.val());
updateLabelColor();
send(); send();
}); }).on("change", updateLabelColor);
reflb.on("change", function (event) { reflb.on("change", function (event) {
var value = (ob.unit === "float" ? parseFloat : parseInt)(event.target.value); var value = (ob.unit === "float" ? parseFloat : parseInt)(event.target.value);
if(Number.isNaN(value) || value > ob.max || value < ob.min) { if(Number.isNaN(value) || (ob.min >= 0 && value < 0)) {
event.target.value = refin.val(); event.target.value = refin.val();
return; return;
} }
@ -193,6 +202,7 @@ function addSetting(ob) {
} }
refin.val(value); refin.val(value);
reflb.val(value); reflb.val(value);
updateLabelColor();
send(); send();
}); });
} else if(ob.uitype == "toggle"){ } else if(ob.uitype == "toggle"){
@ -2065,48 +2075,48 @@ $(document).ready(function(){
newTextHighlight($("#n"+msg.data)) newTextHighlight($("#n"+msg.data))
} else if(msg.cmd == "updatetemp") { } else if(msg.cmd == "updatetemp") {
// Send current temp value to input // Send current temp value to input
$("#settemp").val(parseFloat(msg.data));
$("#settempcur").val(msg.data); $("#settempcur").val(msg.data);
$("#settemp").val(parseFloat(msg.data)).trigger("change");
} else if(msg.cmd == "updatetopp") { } else if(msg.cmd == "updatetopp") {
// Send current top p value to input // Send current top p value to input
$("#settopp").val(parseFloat(msg.data));
$("#settoppcur").val(msg.data); $("#settoppcur").val(msg.data);
$("#settopp").val(parseFloat(msg.data)).trigger("change");
} else if(msg.cmd == "updatetopk") { } else if(msg.cmd == "updatetopk") {
// Send current top k value to input // Send current top k value to input
$("#settopk").val(parseFloat(msg.data));
$("#settopkcur").val(msg.data); $("#settopkcur").val(msg.data);
$("#settopk").val(parseFloat(msg.data)).trigger("change");
} else if(msg.cmd == "updatetfs") { } else if(msg.cmd == "updatetfs") {
// Send current tfs value to input // Send current tfs value to input
$("#settfs").val(parseFloat(msg.data));
$("#settfscur").val(msg.data); $("#settfscur").val(msg.data);
$("#settfs").val(parseFloat(msg.data)).trigger("change");
} else if(msg.cmd == "updatetypical") { } else if(msg.cmd == "updatetypical") {
// Send current typical value to input // Send current typical value to input
$("#settypical").val(parseFloat(msg.data));
$("#settypicalcur").val(msg.data); $("#settypicalcur").val(msg.data);
$("#settypical").val(parseFloat(msg.data)).trigger("change");
} else if(msg.cmd == "updatereppen") { } else if(msg.cmd == "updatereppen") {
// Send current rep pen value to input // Send current rep pen value to input
$("#setreppen").val(parseFloat(msg.data));
$("#setreppencur").val(msg.data); $("#setreppencur").val(msg.data);
$("#setreppen").val(parseFloat(msg.data)).trigger("change");
} else if(msg.cmd == "updatereppenslope") { } else if(msg.cmd == "updatereppenslope") {
// Send current rep pen value to input // Send current rep pen value to input
$("#setreppenslope").val(parseFloat(msg.data));
$("#setreppenslopecur").val(msg.data); $("#setreppenslopecur").val(msg.data);
$("#setreppenslope").val(parseFloat(msg.data)).trigger("change");
} else if(msg.cmd == "updatereppenrange") { } else if(msg.cmd == "updatereppenrange") {
// Send current rep pen value to input // Send current rep pen value to input
$("#setreppenrange").val(parseFloat(msg.data));
$("#setreppenrangecur").val(msg.data); $("#setreppenrangecur").val(msg.data);
$("#setreppenrange").val(parseFloat(msg.data)).trigger("change");
} else if(msg.cmd == "updateoutlen") { } else if(msg.cmd == "updateoutlen") {
// Send current output amt value to input // Send current output amt value to input
$("#setoutput").val(parseInt(msg.data));
$("#setoutputcur").val(msg.data); $("#setoutputcur").val(msg.data);
$("#setoutput").val(parseInt(msg.data)).trigger("change");
} else if(msg.cmd == "updatetknmax") { } else if(msg.cmd == "updatetknmax") {
// Send current max tokens value to input // Send current max tokens value to input
$("#settknmax").val(parseInt(msg.data));
$("#settknmaxcur").val(msg.data); $("#settknmaxcur").val(msg.data);
$("#settknmax").val(parseInt(msg.data)).trigger("change");
} else if(msg.cmd == "updateikgen") { } else if(msg.cmd == "updateikgen") {
// Send current max tokens value to input // Send current max tokens value to input
$("#setikgen").val(parseInt(msg.data));
$("#setikgencur").val(msg.data); $("#setikgencur").val(msg.data);
$("#setikgen").val(parseInt(msg.data)).trigger("change");
} else if(msg.cmd == "setlabeltemp") { } else if(msg.cmd == "setlabeltemp") {
// Update setting label with value from server // Update setting label with value from server
$("#settempcur").val(msg.data); $("#settempcur").val(msg.data);
@ -2310,15 +2320,15 @@ $(document).ready(function(){
$("#setnumseqcur").html(msg.data); $("#setnumseqcur").html(msg.data);
} else if(msg.cmd == "updatenumseq") { } else if(msg.cmd == "updatenumseq") {
// Send current max tokens value to input // Send current max tokens value to input
$("#setnumseq").val(parseInt(msg.data));
$("#setnumseqcur").html(msg.data); $("#setnumseqcur").html(msg.data);
$("#setnumseq").val(parseInt(msg.data)).trigger("change");
} else if(msg.cmd == "setlabelwidepth") { } else if(msg.cmd == "setlabelwidepth") {
// Update setting label with value from server // Update setting label with value from server
$("#setwidepthcur").html(msg.data); $("#setwidepthcur").html(msg.data);
} else if(msg.cmd == "updatewidepth") { } else if(msg.cmd == "updatewidepth") {
// Send current max tokens value to input // Send current max tokens value to input
$("#setwidepth").val(parseInt(msg.data));
$("#setwidepthcur").html(msg.data); $("#setwidepthcur").html(msg.data);
$("#setwidepth").val(parseInt(msg.data)).trigger("change");
} else if(msg.cmd == "updateuseprompt") { } else if(msg.cmd == "updateuseprompt") {
// Update toggle state // Update toggle state
$("#setuseprompt").prop('checked', msg.data).change(); $("#setuseprompt").prop('checked', msg.data).change();

View File

@ -22,6 +22,14 @@ chunk.editing, chunk.editing * {
font-style: normal !important; font-style: normal !important;
} }
.setting-value-warning {
color: #ff7777;
}
.setting-value-warning:focus {
color: #ffaaaa !important;
}
.settinglabel input { .settinglabel input {
width: 5ch; width: 5ch;
background-color: inherit; background-color: inherit;

View File

@ -9,7 +9,7 @@
<link rel="stylesheet" href="static/bootstrap.min.css"> <link rel="stylesheet" href="static/bootstrap.min.css">
<link rel="stylesheet" href="static/bootstrap-toggle.min.css"> <link rel="stylesheet" href="static/bootstrap-toggle.min.css">
<link rel="stylesheet" href="static/open-iconic-bootstrap.min.css"> <link rel="stylesheet" href="static/open-iconic-bootstrap.min.css">
<link rel="stylesheet" href="static/custom.css?ver=1.17a"> <link rel="stylesheet" href="static/custom.css?ver=1.17c">
<script src="static/jquery-3.6.0.min.js"></script> <script src="static/jquery-3.6.0.min.js"></script>
<script src="static/jquery-ui.sortable.min.js"></script> <script src="static/jquery-ui.sortable.min.js"></script>
@ -17,7 +17,7 @@
<script src="static/bootstrap.min.js"></script> <script src="static/bootstrap.min.js"></script>
<script src="static/bootstrap-toggle.min.js"></script> <script src="static/bootstrap-toggle.min.js"></script>
<script src="static/rangy-core.min.js"></script> <script src="static/rangy-core.min.js"></script>
<script src="static/application.js?ver=1.17f"></script> <script src="static/application.js?ver=1.17g"></script>
</head> </head>
<body> <body>
<input type="file" id="remote-save-select" accept="application/json" style="display:none"> <input type="file" id="remote-save-select" accept="application/json" style="display:none">