Aug 9, 2011

HTML 5 Canvas clock in Drupal

  • Download Needed files...
    • download coolclock.js file from here
    • download moreskins.js file from here
    • For IE versions download excanvas.js file from [latest version of excanvas.js] here
  • Next create a block in drupal admin/build/block and,
  • Link all the above files in the block
    • eg: 
      • script type="text/javascript"src="/path0/path1/path2/coolclock.js"></script
      • script type="text/javascript" src="/path0/path1/path2/moreskins.js"></script 
      • NOTE : and for IE 6,7,8 (you should add the conditional script)
        •   eg:
           <!--[if IE]>
          <script type="text/javascript" src="/path0/path1/path2/excanvas.js"></script>

  • And then then add the canvas tag which calls the clock
    canvas id="c1" class="CoolClock" width="60" height="60" style="width: 170px; height: 170px; "></canvas
  • It should probably work in all major browsers (Firfox, Google Chrome, Safari, Opera) but not in IE 5 +
  • In-order to fix it in IE include the below function in the body load event, “CoolClock.findAndCreateClocks()”
    • eg: body onload="CoolClock.findAndCreateClocks()"
  • Viola!!!!!! Enjoy HTML5 Canvas Clock

Follow by Email