Forum Moderators: open
My idea was to store the time on the server in an application variable each time a pick was made and when the hidden page updates every 10 seconds, return the offset between that time and current server time. Then update the timer on the client browser according to that offset time. Problem is, I'm not sure how to do to things:
1...How do I find the offset between the last pick time and current time on the server using VBScript?
2...How do I translate that into seconds and minutes to display using JavaScript on the client.
Anybody got an idea or a link to some VBScript time functions for me? I would think I would want to store the time difference as a number of seconds and return that to the browser, then adjust my stopwatch timer to be that many seconds starting from 0.
even if it is possible (use timer(), pass the last creation time if your hidden page on it's refresh back to server and calculate the new offset in that vbscript), you won't be able to synchronize that good because of connection time. you don't know, how long the time will be between the creation of the page and it's display. this could be up to 10 seconds if the connection to your user hangs. this gap you can't close and calculate.
what might be a better solution is to create a timestamp of the browsers time and calculate an offset to your servertime. then this could be synced in javascript on the users page all the time.
Thanks, actually, I think for my purposes that may work fine. I'm not really worried about keeping the timers in exact synch. A 10-20 second margin of error is probably acceptable. The main thing is to sort of keep people from closing their browser and opening it back up again or even just hitting refresh to gain time...and to impose some sort of something so that I can say to them, hey, don't worry if your timer goes up to 3:30 seconds or so, but if it hits 4 minutes, something may be wrong and the commish might need to force a pick. I hadn't really thought about the load time problem :) I may need to add a button for the commish to give people extra time by resetting the last pick time to be the current time. Just in case somebody does have a problem and can't load the page or something for a long time.