This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes is this recursive call safe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "is this recursive call safe" Watch "is this recursive call safe" New topic
Author

is this recursive call safe

J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 826
    
  13

This request is for a page that will be displayed as one of a series of pages in kiosk mode. The page will display for about 20 seconds before the next page in the sequence. User has requested that the background "pulse" or animate several shades of red in order to draw attention to the important message on the page. Here's what I've come up with.



I have two concerns. First, is this sort of recursive call safe or is it just going to consume memory until the browser crashes? I've seen lots of examples that use this kind of code, but that doesn't mean it's a good idea. If it's a bad idea, what's the alternative?

Second, the background goes white momentarily at the end of the loop before starting the loop again and I can't figure out why. I'm watching the style code in firebug and at the end of the loop it says "style=backgroundColor: rgb{165, 000, 000}". I never see it go to rgb(255, 255, 255} even if I increase the time delay.




"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60748
    
  65

If the page refreshes every 20 seconds, I don't think you have any memory leak worries. (Except maybe in older versions of IE.)

If you are concerned about the recursive nature, you should be using the effects queue in any case. (See the .queue() method.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 826
    
  13

Thanks, I'll read up on the effects queue. I remember seeing mention of that in JQIA, but it was over my head at the time. I've grown a little since then.

I don't suppose you have any thoughts on that momentary switch to a white background? I've slowed it down to 2000 ms between transitions and still can't see anything that sets the background to anything other than the values I've defined. Same in Firefox or IE.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60748
    
  65

Re: white flash. Not off the top of my head.

Give the section on queueing in chapter 5 another go! Yehuda thinks it's the best explanation of jQuery queueing out there, and I'm not gonna argue with him.
 
jQuery in Action, 2nd edition
 
subject: is this recursive call safe
 
Similar Threads
Clear email field after submit
help me create Go! game please
recursive
Client side validation not working
dynamic color