cyberstream / Fix-the-Web

**NOT MAINTAINED** Main repository for "Fix the Web", an open source Opera extension
4 stars 3 forks source link

setTimeout probably used in a wrong way #17

Closed martinkadlec0 closed 12 years ago

martinkadlec0 commented 12 years ago

Hi, in backgroud.js on line 291 you have this code:

setTimeout(update(), (widget.preferences.getItem("update-interval") * 1000 * 60));

The first parameter of the setTimeout function should be the function, not its return value (which is "undefined" in this case bacuse "update" function has no "return")

So it should be imo:

setTimeout(update, (widget.preferences.getItem("update-interval") * 1000 * 60));

metude commented 12 years ago

Thanks for contribution. Greench or Eli will care with this and merge it. If you have any suggestion or contribution share with us.

cyberstream commented 12 years ago

You are right. Thanks for fixing that!

BTW, it is important to note that using setTimeout() will not actually update the CSS patches file as often as it is specified in the preferences. It will update it more often: each time the background process is loaded it will run the update function, THEN it will run it by the specified interval.

I'm not sure how the background process works. Is there one background process running for every page? In other words, if I had three tabs open, are there three instances of the background process running simultaneously?

Either way, I updated the CSS patches updater function. I will push it to Github soon.

martinkadlec0 commented 12 years ago

There is only one background process per extension.

cyberstream commented 12 years ago

Excellent, thank you. That's good to know.