/* ============ appcuarium ============ Alfie ® Platform JS SDK ====== Apps outside the box.® ====== ------------------------------------ Copyright © 2012 Appcuarium ------------------------------------ apps@appcuarium.com @author Sorin Gheata @version 1.1.0 ==================================== Alfie Weather plugin */ if(typeof Object.create!=="function"){Object.create=function(e){function t(){}t.prototype=e;return new t}}(function(e,t,r,i){var s={init:function(t,n){var r=this;r.elem=n;r.$elem=e(n);r.options=e.extend({},e.fn.alfie.options,t);r.query="";r.searchInput=e("#widgets-right #search-location");r.template=e.trim(e("#weather-template").html());r.route()},route:function(){var e=this;action=e.options.action;return e.executeQuery(action)},executeQuery:function(t){var n=this;if(typeof t==="string"){var r=t.split(/[ ,]+/),i=r.length;return e.when(n[r].call(n)).done(function(e){})}else if(typeof t==="object"){e.each(t,function(t,r){if(r.next){next=r.next;e.when(n[t].call(n,r)).pipe(function(e){return n[next].call(n,e)}).then(function(e){console.log(t+" Resolved -> Chained done for: "+e)},function(e){console.log(t+" Rejected: Reason -> "+e)})}else{return n[t].call(n,r)}})}},searchDelayed:function(e){var t=this;t.searchInput.on("keyup",t.search)},search:function(){var t=s,n=this,r=e.Deferred();clearTimeout(t.timer);t.timer=n.value.length>=3&&setTimeout(function(){t.query=n.value;now=new Date;var i='select * from geo.places where text="'+t.query+'"',s="http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent(i)+"&rnd="+now.getFullYear()+now.getMonth()+now.getDay()+now.getHours()+"&format=json&callback=?";e.when(t.fetch(s,"json")).then(function(n){e.when(t.build(n)).done(function(t){e("#widgets-right #cities").html(t)});r.resolve()})},400);return r.promise()},get_weather:function(t){var n=s;e.when(n.fetch(alfie.path+"/alfie-wp-weather/getfeed.php","json",t.params)).then(function(t){e.when(n.build_weather_widget(t)).done(function(e){})})},getTimeAsDate:function(e){var t=new Date,n=new Date(t.toDateString()+" "+e);return n},build_weather_widget:function(t){var r=this,i=e.Deferred(),s=e.trim(e("#widget-template").html()),o=e("