Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:10:25+00:00 2026-05-28T13:10:25+00:00

My problem: I have an JSON Array containing arrays, which i render into the

  • 0

My problem: I have an JSON Array containing arrays, which i render into the body tag – so that it looks like this:

<body data-flashes="[["message","Welcome"],["error","This is working!"],["",""]]">

i want to do the following:

  1. go each element in the outer array
  2. the first element in the inner array will become the classname of a span
  3. the second element in the inner array will become the text in a span
  4. animate the span
  5. wait 10 seconds
  6. start over again

( its always the same span)
my try:

window.pause = ( ms ) -> (
    date = new Date()
    currentDate = null

    loop
        currentDate = new Date()
        break unless currentDate-date < ms
)
window.showFlashes = () -> (
    $.each( window.$('body').data('flashes'), () -> (
            window.$('#flash_container').attr( 'class', this[0] )
            window.$('#flash_container').text( this[1] )
            window.$('#flash_container').effect( 'pulsate' )

            alert this

            pause( 10000 )
        )
    )
)

this is coffeescript which rails renders into following javascript-file:

(function() {

  window.pause = function(ms) {
    var currentDate, date, _results;
    date = new Date();
    currentDate = null;
    _results = [];
    while (true) {
      currentDate = new Date();
      if (!(currentDate - date < ms)) {
        break;
      } else {
        _results.push(void 0);
      }
    }
    return _results;
  };

  window.showFlashes = function() {
    return $.each(window.$('body').data('flashes'), function() {
      window.$('#flash_container').attr('class', this[0]);
      window.$('#flash_container').text(this[1]);
      window.$('#flash_container').effect('pulsate');
      alert(this);
      return pause(10000);
    });
  };

  window.exit_after = function(ms) {
    var _results;
    setTimeout("return 0", ms);
    _results = [];
    while (true) {
      _results.push(ms = 1);
    }
    return _results;
  };

}).call(this);

now the “real” problem: as long as i have the alert this in the code it works fine (besides that the animation is not working). but when i remove it, the code stops working.

and my second problem is: is there a way to get around the pause function? i would rather like to use setTimeout(), but i dont know how to…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:10:25+00:00Added an answer on May 28, 2026 at 1:10 pm

    setTimeout() is the solution to all of this.

    It takes two arguments, the first being a string to be executed and the second to be the delay in milliseconds from now.

    To ease this, I would wrap your block of code in a function and then call this function using setTimeout(). For instance:

    function do_stuff()
    {
    ...
    }
    
    setTimeout("do_stuff()",10000);
    

    Would mean that do_stuff() is going to be called in 10seconds time.

    I hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I everyone i have a JSON Array that is construct like this for (var
I have a problem using JSON and arrays. Here is my code: while($row =
I have a returned JSON string which I have parsed and put through into
I have several string each containing a JSON representation of an array of objects.
I have this form: http://jsfiddle.net/michelejs/Pt6LQ/ The problem is that I am not be able
I need help to solve this problem: I have a csv file like this
I have a Json array that contains latitude and longitude coordinates. Here's a sample:
I have a little problem using jQuery and sorting a JSON array. What I'm
I have a php command that like this. $query = SELECT * FROM $table
I have a problem accessing JSON data. I'm new to JSON and jquery so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.