Showing posts with label Webpart. Show all posts
Showing posts with label Webpart. Show all posts

Office365 Weather WebPart

A while ago I wrote a Sharepoint web part that displayed a 5 day weather forecast for a user configurable location using Met Office data from the Azure Datamarket. I wanted to try porting this web part to Office365, to see if I could overcome the challenges of working predominantly client side using Javascript.

With the help of jQuery to make ajax requests to the Datamarket and a cryptographic library to encrypt the username and password that is included in the ajax request headers I've managed to accomplish this goal.

One of the major challenges was to overcome the cross site scripting issues, where I was making requests to the Datamarket from the Office365 domain. The Datamarket supports the oData standard well from a .Net Framework perspective, but it requires user interaction to allow the request from a purely web client or javascript approach. Internet Explorer has an object called a XDomainRequest which is specifically designed for cross site data requests, the only problem is that you can't include any headers, which means that authentication was ruled out. Aparently IE 10 will work the same way that Chrome does now and properly support jQuery CORS. So, I had to compromise and change internet explorer's security settings to allow cross site data requests.

I've just published the code in a CodePlex project here: http://o365Weather.codeplex.com

Sharepoint 2010 Weather WebPart

Here's my latest CodePlex Sharepoint 2010 project, it's a WebPart that displays a 5 day weather forecast.


The weather feed is from the Microsoft "Dallas" Project, you must sign up at www.sqlazureservices.com and subscribe to the Weather Central Global Forecast and Data Services - Weather Central, LLC (CTP2). You will need to enter your Account Key into the WebPart properties.

The location of the forecast is controlled by entering Latitude and Longitude values in the WebPart properties. I found this site very useful to search for a location and get the Latitude and Longitude values.

The images and stylesheet are loaded into the Site Collection Style Library. Any user who has access to this can change the weather icons or styles that the WebPart uses.

Note: Please make sure you have the necessary permissions/rights to use the icon images.