From 0081f1437a30a4fe66725187cf719782ffc71e1a Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sat, 28 Sep 2024 10:04:11 +0200 Subject: [PATCH] debouncing inputs --- changedetectionio/static/js/watch-settings.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/changedetectionio/static/js/watch-settings.js b/changedetectionio/static/js/watch-settings.js index 003f4eb3..34e50d1b 100644 --- a/changedetectionio/static/js/watch-settings.js +++ b/changedetectionio/static/js/watch-settings.js @@ -73,6 +73,7 @@ $(document).ready(function () { const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0); $("#text-preview-inner").css('max-height', (vh-300)+"px"); + var debounced_request_textpreview_update = request_textpreview_update.debounce(100); $("#activate-text-preview").click(function (e) { $(this).fadeOut(); @@ -82,10 +83,8 @@ $(document).ready(function () { $("#text-preview-refresh").click(function (e) { request_textpreview_update(); }); - $('textarea:visible, input:visible').on('keyup keypress blur change click', function (e) { - request_textpreview_update(); - }); - + $('textarea:visible').on('keyup blur', debounced_request_textpreview_update); + $('input:visible').on('keyup blur change', debounced_request_textpreview_update); }); });