author | Jakub Narebski <jnareb@gmail.com> | |
Fri, 27 May 2011 13:50:01 +0000 (15:50 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 27 May 2011 18:00:42 +0000 (11:00 -0700) | ||
commit | 42ab5d40deb6dff37705ce5aa16ac69d859a04e1 | |
tree | d5a7b49dc3bf58a87d185d9b74478e61cfdb8e7b | tree | snapshot |
parent | e8dd0e4063da6d0eecef1a6db99534e41f74b32e | commit | diff |
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 <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/static/js/blame_incremental.js | diff | blob | history |