mpk-ttss icon indicating copy to clipboard operation
mpk-ttss copied to clipboard

Local countdown

Open p0358 opened this issue 7 years ago • 1 comments

  • Add local countdown if departure is close enough (so we get a smooth second-by-second cooldown before the next refresh)
  • Fix ttss_base if project is not installed in web root (a dot for relative path)
  • Fix in map.js for green border if tram is already on stop/loop (as it was done in previous pull request in index.js, didn't notice the one in map.js)

Please review.

p0358 avatar Nov 29 '17 22:11 p0358

I would like to see such changes:

  • do not call loadTimes inside setInterval function - this may cause weird behavior if many trains should arrive in succession (eg. in 2, 4 and 6 seconds - it may result in three calls each canceling the preceding one),
  • IMHO the way to go should be to keep references to <tr> and relevant <td> elements along with actualRelativeTime (maybe use td.dataset),
  • go through all the elements every second and only update text content (plus className), optionally on-demand (ie. compare what is generated with current value and setText if required - but I am not sure how much of a performance hit will incur from not doing it, if any). This would also make should_activate_smooth_timer obsolete.

This would lower both number of modifications and additional code required - pretty much only function for setting status text and proper className should be extracted and used).

As you have stated - updating half of the DOM tree every second is no good.

It would also be unnecessary DOM updating every second without any visual change.

Thanks for the contribution!

jacekkow avatar Nov 30 '17 21:11 jacekkow