mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-01-22 20:40:55 -08:00
add onEdit function for js and rework token-counter.js to use it
This commit is contained in:
parent
7026b96476
commit
c7e810a985
3 changed files with 27 additions and 17 deletions
|
|
@ -366,3 +366,20 @@ function switchWidthHeight(tabname) {
|
|||
updateInput(height);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
var onEditTimers = {};
|
||||
|
||||
// calls func after afterMs milliseconds has passed since the input elem has beed enited by user
|
||||
function onEdit(editId, elem, afterMs, func) {
|
||||
var edited = function() {
|
||||
var existingTimer = onEditTimers[editId];
|
||||
if (existingTimer) clearTimeout(existingTimer);
|
||||
|
||||
onEditTimers[editId] = setTimeout(func, afterMs);
|
||||
};
|
||||
|
||||
elem.addEventListener("input", edited);
|
||||
|
||||
return edited;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue