Adding a functioning javascript or similar date/clock script

lionheart8 - April 13, 2007 - 15:06

Hi,
I want to add a simple date & better still embedded date-clock on my site.
I have tried this in the past, but for some reason they wont work and in fact one world clock completely paralyzed the site & nothing, including log in worked. I had to make a new installation as I didnt know where to go to get rid of it without logging in. This happened on 2, 3 separate installations, some of which were Drupal 4.7.x .
I have since tried many publicly available javascript date/time scripts with no success, which however work elsewhere with no problem at all.

I am sure there must be some Drupal compatible date/time scripts ( I prefer one embedded on a page & not in a text box). Does anyone have such a script or show me where to get them, that are kNOWN TO WORK on Drupal?

thanks.

For anyone interested: This

kees@qrios - March 28, 2008 - 14:15

For anyone interested:
This could be due to the "onload" property of the body tag. This is used in the Drupal template for loading jQuery onload handlers, and a HTML page can handle only one onload call.

So, if you want to use one of the nifty self-refreshing javascript snippets like a clock/timer, u have to use a jQuery onload handler, I have to dig in this myself, cant explain exactly how this is done.

I might get back on this.

Kees

Webbased applicaties, content management systemen, websites, webdesign

This is how I got it working

somnoliento - April 7, 2008 - 11:32
  1. Download the CoolClock files, and save them to your /files/ directory
  2. In your theme's page.tpl.php file, add this to the "head" section, after <?php print $scripts ?>:
    <!--[if IE]><script type="text/javascript" src="/files/excanvas.js"></script><![endif]-->
    <script type="text/javascript" src="/files/coolclock.js"></script>
    <script type="text/javascript" src="/files/moreskins.js"></script>
    <script language="javascript" type="text/javascript">
            if (Drupal.jsEnabled) {
                    $(document).ready(
                      function() { CoolClock.findAndCreateClocks(); }
                    );
            }(jQuery);
    </script>
  3. Add this code to a Full HTML block, or node where you want the clock to appear (modify the 'class' argument, according to Coolclock's documentation:
    <canvas id="clk1" class="CoolClock"></canvas>

I haven't tested it in IE. Other javascript in the page keeps working (like FCKEditor), although I haven't tried it with other scripts (Google Maps, for instance)

Javascript Countdown Timer for Drupal6

jvandervort - April 10, 2008 - 23:01

6.x-2.13 added a REALLY barebones clock. Strictly boring text at this point.

Javascript Countdown Timer

-John

 
 

Drupal is a registered trademark of Dries Buytaert.