]> Lady’s Gitweb - Gitweb/commit
gitweb.js: use setTimeout rather than setInterval in blame_incremental.js
authorJakub Narebski <redacted>
Fri, 27 May 2011 13:50:01 +0000 (15:50 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:31 +0000 (00:51 -0400)
commitb6801f89716495df0d05906be8e12d009abe233933520381c7842cf3fd0978c1
tree0f0b1a152dd52ec3f526d6e37b9176b18c41937a5dcf6f9cfc02ad689d8a1909
parentff3cde0cc388488d18aaee73fffa400e3daa35d77ebc2c52e49c32c48a6a5834
gitweb.js: use setTimeout rather than setInterval in blame_incremental.js

If there is a possibility that your logic could take longer to execute
than the interval time, it is recommended that you recursively call a
named function using window.setTimeout rather than window.setInterval.

Therefore instead of using setInterval as an alternate way of invoking
handleResponse (because some web browsers call onreadystatechange only
once per each distinct state, and not for each server flush), use
setTimeout and reset it from handleResponse.  As a bonus this allows
us to get rid of timer if it turns out that web browser calls
onreadystatechange on each server flush.

While at it get rid of `xhr' global variable, creating it instead as
local variable in startBlame and passing it as parameter, and of
`pollTimer' global variable, passing it as member of xhr object
(xhr.pollTimer).

Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
static/js/blame_incremental.js
This page took 0.315531 seconds and 4 git commands to generate.