On Jun 1, 7:10 pm, David Thomson <[email protected]> wrote: > I have a gadget that gets the electric rates from the local utility > company. I would like the gadget to automatically refresh the data at > 5pm every day, for the next day's rates. What is the best timer > method to call the routine, and that does not tie up system resources > in a continuous loop? I'm a javascript beginner, so please use small > words. :-)
Are you architecting your gadget so that if it happens to be open when the clock strikes 5, it will refresh with the new rates? That's certainly possible, but it's a lot of work for something that only happens once per day. Unless you expect users to be sitting watching your gadget at that moment, waiting for the new rates to be announced, I'd say just build it to load the current rates when it loads. That way it will automatically pick up the latest, whether it loads at 4:59 or 5:01. The only thing you'll need to watch for is the cache timeout in the content retrieval function; see http://tinyurl.com/r6qqh6 for more info. IF you do want it to refresh when the clock hits 5, you'll need to do something like: 1. Save the starting time in a global var 2. Use a setTimeout() to call your refresh-checking function every x seconds (x is up to you). 3. In your refresh-checking function, if the starting time < 5:00 and the current time is > 5:00, then refresh the rates, else start another setTimeout (as in Step 2). HTH, String --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "iGoogle Developer Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Gadgets-API?hl=en -~----------~----~----~----~------~----~------~--~---
