/*
 * 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 <twofivethreetwo@gmail.com>
 * Another project from monkeeCreate <http://monkeecreate.com>
 *
 * Version 1.6 - Last updated: December 16 2010
 *
/*
$("#weather").append('<h2>'+weather.city+', '+weather.region+' '+weather.country+'</h2>');
$("#weather").append('<p><strong>Today\'s High</strong>: '+weather.high+'&deg; '+weather.units.temp+' - <strong>Today\'s Low</strong>: '+weather.low+'&deg; '+weather.units.temp+'</p>');
$("#weather").append('<p><strong>Current Temp</strong>: '+weather.temp+'&deg; '+weather.units.temp+'</p>');
$("#weather").append('<p><strong>Thumbnail</strong>: <img src="'+weather.thumbnail+'"></p>');
$("#weather").append('<p><strong>Wind</strong>: '+weather.wind.direction+' '+weather.wind.speed+' '+weather.units.speed+' <strong>Wind Chill</strong>: '+weather.wind.chill+'</p>');
$("#weather").append('<p><strong>Currently</strong>: '+weather.currently+' - <strong>Forecast</strong>: '+weather.forecast+'</p>');
$("#weather").append('<p><img src="'+weather.image+'"></p>');
$("#weather").append('<p><strong>Humidity</strong>: '+weather.humidity+' <strong>Pressure</strong>: '+weather.pressure+' <strong>Rising</strong>: '+weather.rising+' <strong>Visibility</strong>: '+weather.visibility+'</p>');
$("#weather").append('<p><strong>Sunrise</strong>: '+weather.sunrise+' - <strong>Sunset</strong>: '+weather.sunset+'</p>');
$("#weather").append('<p><strong>Tomorrow\'s Date</strong>: '+weather.tomorrow.day+' '+weather.tomorrow.date+'<br /><strong>Tomorrow\'s High/Low</strong>: '+weather.tomorrow.high+'/'+weather.tomorrow.low+'<br /><strong>Tomorrow\'s Forecast</strong>: '+weather.tomorrow.forecast+'<br /> <strong>Tomorrow\'s Image</strong>: '+weather.tomorrow.image+'</p>');
$("#weather").append('<p><strong>Last updated</strong>: '+weather.updated+'</p>');
$("#weather").append('<p><a href="'+weather.link+'">View forecast at Yahoo! Weather</a></p>');
*/

(function($){$.extend({simpleWeather:function(d){var d=$.extend({zipcode:'76309',location:'',unit:'f',success:function(a){},error:function(a){}},d);var e='http://query.yahooapis.com/v1/public/yql?format=json&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("Nincs lokáció megadva.");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&&currentDate<sunSet)timeOfDay='d';else timeOfDay='n';wind=a.wind.direction;if(wind>338)windDirection="N";else if(wind==0&&wind<24)windDirection="N";else if(wind>=24&&wind<69)windDirection="NE";else if(wind>=69&&wind<114)windDirection="E";else if(wind>=114&&wind<186)windDirection="SE";else if(wind>=186&&wind<204)windDirection="S";else if(wind>=204&&wind<249)windDirection="SW";else if(wind>=249&&wind<294)windDirection="W";else if(wind>=294&&wind<338)windDirection="NW";else windDirection="";var b={title:a.item.title,temp:a.item.condition.temp,units:{temp:a.units.temperature,distance:a.units.distance,pressure:a.units.pressure,speed:a.units.speed},currently:a.item.condition.text,high:a.item.forecast[0].high,low:a.item.forecast[0].low,forecast:a.item.forecast[0].text,wind:{chill:a.wind.chill,direction:windDirection,speed:a.wind.speed},humidity:a.atmosphere.humidity,pressure:a.atmosphere.pressure,rising:a.atmosphere.rising,visibility:a.atmosphere.visibility,sunrise:a.astronomy.sunrise,sunset:a.astronomy.sunset,description:a.item.description,thumbnail:"http://l.yimg.com/a/i/us/nws/weather/gr/"+a.item.condition.code+timeOfDay+"s.png",image:"http://l.yimg.com/a/i/us/nws/weather/gr/"+a.item.condition.code+timeOfDay+".png",tomorrow:{high:a.item.forecast[1].high,low:a.item.forecast[1].low,forecast:a.item.forecast[1].text,date:a.item.forecast[1].date,day:a.item.forecast[1].day,image:"http://l.yimg.com/a/i/us/nws/weather/gr/"+a.item.forecast[1].code+"d.png"},city:a.location.city,country:a.location.country,region:a.location.region,updated:a.item.pubDate,link:a.item.link};d.success(b)})}else{if(c.query.results==null)d.error("Érvénytelen lokáció.");else d.error("Időjárás megjelenítési hiba.")}});return this}})})(jQuery);
