Fossil SCM

Rename some JS vars for clarity. No functional changes.

stephan 2024-08-21 11:36 trunk
Commit abeb57d28e44c2f1cf7d2227be8ecb91c8e57cf7aef210396504cda44ab609bd
1 file changed +8 -8
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -300,24 +300,24 @@
300300
301301
If passed only 1 argument, or passed a falsy 2nd argument,
302302
the default wait time set in this function's $defaultDelay
303303
property is used.
304304
305
- Source: underscore.js, by way of https://davidwalsh.name/javascript-debounce-function
305
+ Inspiration: underscore.js, by way of https://davidwalsh.name/javascript-debounce-function
306306
*/
307
- F.debounce = function f(func, wait, immediate) {
308
- var timeout;
309
- if(!wait) wait = f.$defaultDelay;
307
+ F.debounce = function f(func, waitMs, immediate) {
308
+ var timeoutId;
309
+ if(!waitMs) waitMs = f.$defaultDelay;
310310
return function() {
311311
const context = this, args = Array.prototype.slice.call(arguments);
312312
const later = function() {
313
- timeout = undefined;
313
+ timeoutId = undefined;
314314
if(!immediate) func.apply(context, args);
315315
};
316
- const callNow = immediate && !timeout;
317
- clearTimeout(timeout);
318
- timeout = setTimeout(later, wait);
316
+ const callNow = immediate && !timeoutId;
317
+ clearTimeout(timeoutId);
318
+ timeoutId = setTimeout(later, waitMs);
319319
if(callNow) func.apply(context, args);
320320
};
321321
};
322322
F.debounce.$defaultDelay = 500 /*arbitrary*/;
323323
324324
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -300,24 +300,24 @@
300
301 If passed only 1 argument, or passed a falsy 2nd argument,
302 the default wait time set in this function's $defaultDelay
303 property is used.
304
305 Source: underscore.js, by way of https://davidwalsh.name/javascript-debounce-function
306 */
307 F.debounce = function f(func, wait, immediate) {
308 var timeout;
309 if(!wait) wait = f.$defaultDelay;
310 return function() {
311 const context = this, args = Array.prototype.slice.call(arguments);
312 const later = function() {
313 timeout = undefined;
314 if(!immediate) func.apply(context, args);
315 };
316 const callNow = immediate && !timeout;
317 clearTimeout(timeout);
318 timeout = setTimeout(later, wait);
319 if(callNow) func.apply(context, args);
320 };
321 };
322 F.debounce.$defaultDelay = 500 /*arbitrary*/;
323
324
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -300,24 +300,24 @@
300
301 If passed only 1 argument, or passed a falsy 2nd argument,
302 the default wait time set in this function's $defaultDelay
303 property is used.
304
305 Inspiration: underscore.js, by way of https://davidwalsh.name/javascript-debounce-function
306 */
307 F.debounce = function f(func, waitMs, immediate) {
308 var timeoutId;
309 if(!waitMs) waitMs = f.$defaultDelay;
310 return function() {
311 const context = this, args = Array.prototype.slice.call(arguments);
312 const later = function() {
313 timeoutId = undefined;
314 if(!immediate) func.apply(context, args);
315 };
316 const callNow = immediate && !timeoutId;
317 clearTimeout(timeoutId);
318 timeoutId = setTimeout(later, waitMs);
319 if(callNow) func.apply(context, args);
320 };
321 };
322 F.debounce.$defaultDelay = 500 /*arbitrary*/;
323
324

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button