mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-17 20:20:45 +01:00
make the throttle timer a dict to keep track of which slider has been changed
This commit is contained in:
parent
1de4944d46
commit
6ed50ee1e9
@ -132,14 +132,15 @@ var sliders_throttle = getThrottle(250);
|
|||||||
* @return {(function(*): void)|*} function that takes the ms to wait and a callback to execute after the timer
|
* @return {(function(*): void)|*} function that takes the ms to wait and a callback to execute after the timer
|
||||||
*/
|
*/
|
||||||
function getThrottle(ms) {
|
function getThrottle(ms) {
|
||||||
var timer;
|
var timer = {};
|
||||||
|
|
||||||
return function (callback) {
|
return function (id, callback) {
|
||||||
if (timer) {
|
if (timer[id]) {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer[id]);
|
||||||
}
|
}
|
||||||
timer = setTimeout(function () {
|
timer[id] = setTimeout(function () {
|
||||||
callback();
|
callback();
|
||||||
|
delete timer[id];
|
||||||
}, ms);
|
}, ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +176,7 @@ function addSetting(ob) {
|
|||||||
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
|
||||||
refin.on("input", function () {
|
refin.on("input", function () {
|
||||||
sliders_throttle(function () {
|
sliders_throttle(ob.id, function () {
|
||||||
socket.send({'cmd': $(this).attr('id'), 'data': $(this).val()});
|
socket.send({'cmd': $(this).attr('id'), 'data': $(this).val()});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user