I'm newbie to ruby on rails.
In my application, i was trying to show the remaining time the user is
allowed to edit an instance record( like milestones, cheklists etc.).
I was locking it from multiple users to edit it at the sametime.
When the user clicks the edit link_to i need to display the timer in
the edit.rhtml


I have the javascript function for timer updation. when called it
updates the text_field with the time.

function update_timer() {
        var page_loaded_ms = new Date().getTime();
        var timeout_ms = 100*1000;
        var time_left = Math.round((timeout_ms - new Date().getTime()
+ page_loaded_ms) / 1000);
        var minutes = Math.floor(time_left/60);
        var seconds = time_left - (minutes*60);
        $('time_left_value').value = 'Time left: '+ minutes + ' min' +
zeroPad(seconds, 2)+ ' sec';
        setTimeout("update_timer()", 1000);
}

function zeroPad(number, width) {
        var s = number.toString();
        while (s.length < width)
                s = "0" + s;
        return s;
}

could anyone suggest me a solution for this.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to