mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Merge 'nolialsea/patch-1' into settings without Colab changes
This commit is contained in:
@ -118,10 +118,33 @@ var adventure = false;
|
||||
// Chatmode
|
||||
var chatmode = false;
|
||||
|
||||
var sliders_throttle = getThrottle(200);
|
||||
|
||||
//=================================================================//
|
||||
// METHODS
|
||||
//=================================================================//
|
||||
|
||||
/**
|
||||
* Returns a function that will automatically wait for X ms before executing the callback
|
||||
* The timer is reset each time the returned function is called
|
||||
* Useful for methods where something is overridden too fast
|
||||
* @param ms milliseconds to wait before executing the callback
|
||||
* @return {(function(*): void)|*} function that takes the ms to wait and a callback to execute after the timer
|
||||
*/
|
||||
function getThrottle(ms) {
|
||||
var timer = {};
|
||||
|
||||
return function (id, callback) {
|
||||
if (timer[id]) {
|
||||
clearTimeout(timer[id]);
|
||||
}
|
||||
timer[id] = setTimeout(function () {
|
||||
callback();
|
||||
delete timer[id];
|
||||
}, ms);
|
||||
}
|
||||
}
|
||||
|
||||
function addSetting(ob) {
|
||||
// Add setting block to Settings Menu
|
||||
if(ob.uitype == "slider"){
|
||||
@ -153,8 +176,14 @@ function addSetting(ob) {
|
||||
window["label_"+ob.id] = reflb; // Is this still needed?
|
||||
// Add event function to input
|
||||
refin.on("input", function () {
|
||||
socket.send({'cmd': $(this).attr('id'), 'data': $(this).val()});
|
||||
});
|
||||
var that = this;
|
||||
sliders_throttle(ob.id, function () {
|
||||
socket.send({'cmd': $(that).attr('id'), 'data': $(that).val()});
|
||||
refin.val(parseFloat($(that).val()));
|
||||
reflb.html($(that).val());
|
||||
});
|
||||
}
|
||||
);
|
||||
} else if(ob.uitype == "toggle"){
|
||||
settings_menu.append("<div class=\"settingitem\">\
|
||||
<input type=\"checkbox\" data-toggle=\"toggle\" data-onstyle=\"success\" id=\""+ob.id+"\">\
|
||||
|
Reference in New Issue
Block a user