Hello Group. I got my first page up and running and now I''m trying to make it look a bit nicer. I was thinking about putting a clock on the page, can anyone point me to a tutorial or have a routine already done? I''m currently using the Time.now(:short) form, but that is just static. Anyway any help would be greatly appreciated Thanks James --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
No Ruby required. Just use JavaScript.. http://www.javascript-page.com/clock.html Preston On Mar 19, 2007, at 9:03 PM, James wrote:> > Hello Group. > I got my first page up and running and now I''m trying to make it look > a bit nicer. > I was thinking about putting a clock on the page, can anyone point me > to a tutorial or have a routine already done? > I''m currently using the Time.now(:short) form, but that is just > static. > Anyway any help would be greatly appreciated > Thanks > James > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
chanin.makarukpinyo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-22 12:00 UTC
Re: Digital Clock
try AJAX periodically_call_remote example # demo4.rhtml <h1>Test periodically_call_remote</h1> <div id=''show_date_time_id'' style="background-color: #eee"></div> <%= periodically_call_remote(:update => ''show_date_time_id'',:url => { :action => :show_date_time }, :frequency => 1 )%> # ajax_controller.rb def show_date_time render :text=>"Now : #{DateTime.now.to_s}" end On Mar 20, 11:03 am, "James" <tvwatc...-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote:> Hello Group. > I got my first page up and running and now I''m trying to make it look > a bit nicer. > I was thinking about putting a clock on the page, can anyone point me > to a tutorial or have a routine already done? > I''m currently using the Time.now(:short) form, but that is just > static. > Anyway any help would be greatly appreciated > Thanks > James--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
chanin.makarukpinyo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-22 12:00 UTC
Re: Digital Clock
try AJAX periodically_call_remote example # demo4.rhtml <h1>Test periodically_call_remote</h1> <div id=''show_date_time_id'' style="background-color: #eee"></div> <%= periodically_call_remote(:update => ''show_date_time_id'',:url => { :action => :show_date_time }, :frequency => 1 )%> # ajax_controller.rb def show_date_time render :text=>"Now : #{DateTime.now.to_s}" end On Mar 20, 11:03 am, "James" <tvwatc...-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote:> Hello Group. > I got my first page up and running and now I''m trying to make it look > a bit nicer. > I was thinking about putting a clock on the page, can anyone point me > to a tutorial or have a routine already done? > I''m currently using the Time.now(:short) form, but that is just > static. > Anyway any help would be greatly appreciated > Thanks > James--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That would be a very unwise decision, for quite a number of reasons: 1) Your server will be bombarded with requests 2) The clock will never show the right time, because of latency between the request and the response. So, if you want to show the right time, use client-side javascript, period. On 22 Mar 2007, at 13:00, chanin.makarukpinyo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> try AJAX periodically_call_remote > > example > > # demo4.rhtml > <h1>Test periodically_call_remote</h1> > <div id=''show_date_time_id'' style="background-color: #eee"></div> > <%= periodically_call_remote(:update => ''show_date_time_id'',:url => > { :action => :show_date_time }, > :frequency => 1 )%> > > # ajax_controller.rb > def show_date_time > render :text=>"Now : #{DateTime.now.to_s}" > endBest regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I thought the same thing, just imagine one lets the browsertab open for hours without any further action. Anyway, I need to show my users the servertime, there might be a difference to the users machinetime, even if we are talking about a few minutes, so the best would be to make an initial call to rubys TimeClass for getting the servertime and from then on to display/update the time clientside. Even if it´s offtopic, if someone has an approach it would be very welcome matthi> That would be a very unwise decision, for quite a number of reasons: > > 1) Your server will be bombarded with requests > 2) The clock will never show the right time, because of latency > between the request and the response. > > So, if you want to show the right time, use client-side javascript, > period. > > On 22 Mar 2007, at 13:00, chanin.makarukpinyo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > <mailto:chanin.makarukpinyo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> try AJAX periodically_call_remote >> >> >> example >> >> >> # demo4.rhtml >> >> <h1>Test periodically_call_remote</h1> >> >> <div id=''show_date_time_id'' style="background-color: #eee"></div> >> >> <%= periodically_call_remote(:update => ''show_date_time_id'',:url => >> >> { :action => :show_date_time }, >> >> :frequency => 1 )%> >> >> >> # ajax_controller.rb >> >> def show_date_time >> >> render :text=>"Now : #{DateTime.now.to_s}" >> >> end >> > > > > Best regards > > > Peter De Berdt > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 23 Mar 2007, at 09:59, matthibcn wrote:> I thought the same thing, just imagine one lets the browsertab open > for > hours without any further action. > > Anyway, I need to show my users the servertime, there might be a > difference to the users machinetime, even if we are talking about a > few > minutes, so the best would be to make an initial call to rubys > TimeClass > for getting the servertime and from then on to display/update the time > clientside. > > Even if it´s offtopic, if someone has an approach it would be very > welcomeAlthough it wouldn''t exactly be 100% accurate, it would only differ a few seconds from the actual server time. Calculate the offset from the server time with the client''s time using one request, then display the client side time plus or minus the offset. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If someone could give an example or link on how to calculate the offset between clientside and serverside times that would be great. Thank you in advance. Peter De Berdt wrote:> On 23 Mar 2007, at 09:59, matthibcn wrote: > >> clientside. >> >> Even if it´s offtopic, if someone has an approach it would be very >> welcome > > Although it wouldn''t exactly be 100% accurate, it would only differ a > few seconds from the actual server time. Calculate the offset from > the server time with the client''s time using one request, then > display the client side time plus or minus the offset. > > > Best regards > > Peter De Berdt-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Answering my on question but after searching google finally found a solution. Here is the link if anyones interested. http://www.geocities.com/lok_2000_tom/clock.htm Only change function sClock values in the hours, minutes and seconds to rubys Time.now.strftime("%H") for hours and so on. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---