Quick and Dirty Scripting

A blog that focuses on automating system administration tasks for Linux, Windows, and VMware ESX

Thursday, October 15, 2009

 

Time zone Clocks with SharePoint using jQuery

I work with a lot people who are spread across the global so we are always trying to find out what is their local time. While Google has a great query that will convert time for you, I wanted to see if I could create a SharePoint page that will list the times in all the zones that we have people on the team. I found a great blog post on ‘Path to Sharepoint’ (http://pathtosharepoint.wordpress.com/2009/01/09/world-clock/) did exactly what I wanted. The one catch was that he used a lot of JavaScript to convert the calculated text column to HTML. I wondered if jQuery could make it easier. This is what I came up with . . .

  1: <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  2: <script type="text/javascript">
  3:     //load jQuery
  4:     google.load("jquery", "1.3.2");
  5: </script>
  6:
  7: <script type="text/javascript">
  8: $(function() {
  9:     $("td.ms-stylebody:contains('DIV')").each(function(){
 10:         $(this).html($(this).text());
 11:     });
 12: });
 13: </script>

There are a couple requirements for this to work.



  1. The list view was set to boxed.
  2. The calculated column had this equation:
  3. ="<DIV id='calchtml'><embed src='http://www.clocklink.com/clocks/5001-blue.swf?TimeZone="&TimeZone&"'
    width='250' height='70' wmode='transparent' type='application/x-shockwave-flash'></DIV>"

If you follow the instructions at ‘Path to SharePoint’ and use this jQuery you should get something like this:




Archives

October 2007   November 2007   December 2007   January 2008   February 2008   April 2008   October 2009   November 2009  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]