tcellerier / jdigiclock

Javascript digital clock & weather forecast (HTC Hero inspired)
GNU General Public License v3.0
6 stars 7 forks source link

function to stop timers #3

Closed wvhn closed 4 years ago

wvhn commented 4 years ago

Hello,

in my environment I am facing the problem that the timer continues to run even when the page containing jdigiclock has already been left. This causes a lot of useless traffic because the images still get requested every minute in the background.

Since the 'setTimeout' functions in jdigiclock are not assigned to variables, 'clearTimeout' won't work. I have already thought about passing an argument like "start" and "stop" with jdigiclock and then manipulate the main timer in the getdelay-function.

Is there a better idea to stop the timer or even a solution already available?

Thanks Wolfram

wvhn commented 4 years ago

Since the plugin seems to use a local copy of the element object, I did not manage to access that copy by $(document).find(...). So I integrated a parameter „stoptimer“ Into the html element next to the call of digiclock CSS class. Then I Integrated stoptimer into the local control object and changed the displayClock function to execute only if stoptimer is false. Not nice - but it works.

Solution can be viewed here: https://github.com/Martin-Gleiss/smartvisu/blob/develop/lib/clock/jquery.jdigiclock.js