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