Fossil SCM
Rename some JS vars for clarity. No functional changes.
Commit
abeb57d28e44c2f1cf7d2227be8ecb91c8e57cf7aef210396504cda44ab609bd
Parent
e0236194d861e23…
1 file changed
+8
-8
+8
-8
| --- src/fossil.bootstrap.js | ||
| +++ src/fossil.bootstrap.js | ||
| @@ -300,24 +300,24 @@ | ||
| 300 | 300 | |
| 301 | 301 | If passed only 1 argument, or passed a falsy 2nd argument, |
| 302 | 302 | the default wait time set in this function's $defaultDelay |
| 303 | 303 | property is used. |
| 304 | 304 | |
| 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 | |
| 306 | 306 | */ |
| 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; | |
| 310 | 310 | return function() { |
| 311 | 311 | const context = this, args = Array.prototype.slice.call(arguments); |
| 312 | 312 | const later = function() { |
| 313 | - timeout = undefined; | |
| 313 | + timeoutId = undefined; | |
| 314 | 314 | if(!immediate) func.apply(context, args); |
| 315 | 315 | }; |
| 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); | |
| 319 | 319 | if(callNow) func.apply(context, args); |
| 320 | 320 | }; |
| 321 | 321 | }; |
| 322 | 322 | F.debounce.$defaultDelay = 500 /*arbitrary*/; |
| 323 | 323 | |
| 324 | 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 | 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 |