/* * simpleWeather * * A simple jQuery plugin to display the weather information * for a location. Weather is pulled from the public Yahoo! * Weather feed via their api. * * Developed by James Fleeting * Another project from monkeeCreate * * Version 1.9 - Last updated: October 3 2011 */ (function($){$.extend({simpleWeather:function(d){var d=$.extend({zipcode:'76309',location:'',unit:'f',success:function(a){},error:function(a){}},d);now=new Date();var e='http://query.yahooapis.com/v1/public/yql?format=json&rnd='+now.getFullYear()+now.getMonth()+now.getDay()+now.getHours()+'&diagnostics=true&callback=?&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=';if(d.location!='')e+='select * from weather.forecast where location in (select id from weather.search where query="'+d.location+'") and u="'+d.unit+'"';else if(d.zipcode!='')e+='select * from weather.forecast where location in ("'+d.zipcode+'") and u="'+d.unit+'"';else{d.error("No location given.");return false}$.getJSON(e,function(c){if(c!=null&&c.query.results!=null){$.each(c.query.results,function(i,a){if(a.constructor.toString().indexOf("Array")!=-1)a=a[0];currentDate=new Date();sunRise=new Date(currentDate.toDateString()+' '+a.astronomy.sunrise);sunSet=new Date(currentDate.toDateString()+' '+a.astronomy.sunset);if(currentDate>sunRise&¤tDate