PageSourceSearch

https://www.ville-pont-labbe-darnoult.fr/wp-content/cache/min/1/wp…/jquery.flatWeatherPlugin.js?ver=1787914162

js ville-pont-labbe-darnoult.fr collected 2026-10-02 22:36:27 UTC 10,938 bytes, 26 lines download raw bytes

1(function($,window,document,undefined){var pluginName="flatWeatherPlugin";var defaults={location:"Waterloo, ON",country:"Canada",displayCityNameOnly:!1,api:"openweathermap",apikey:"",forecast:5,view:"full",render:!0,loadingAnimation:!0,lang:"fr",};var apiurls={"openweathermap":["https://api.openweathermap.org/data/2.5/weather","https://api.openweathermap.org/data/2.5/forecast/daily"],"yahoo":["https://query.yahooapis.com/v1/public/yql"]};function Plugin(element,options){this.element=element;this.settings=$.extend({},defaults,options);if(!this.settings.units||this.settings.units=="auto"){this.settings.units=(["united states","usa","united states of america","us"].indexOf(this.settings.country.toLowerCase())==-1)?"metric":"imperial"}
2this.settings.forecast=Math.min(this.settings.forecast,5);this._name=pluginName;this.once=!1;this.init()};$.extend(Plugin.prototype,{init:function(){if(this.settings.render){if(this.settings.loadingAnimation&&!this.once){this.loading=$("<div/>",{"id":"flatWeatherLoading","class":"wi loading"});this.loading.appendTo(this.element)}
3this.fetchWeather().then(this.render,this.error)}
4this.once=!0},fetchWeather:function(){var that=this;var promise=new $.Deferred();var params=[];var location=this.settings.location+""+this.settings.country;if(this.settings.api=="openweathermap"){var parameters={};parameters.q=location;parameters.units=this.settings.units;if(this.settings.apikey)parameters.appid=this.settings.apikey;params.push(parameters);parameters.cnt=this.settings.forecast+1;params.push(parameters)}else if(this.settings.api=="yahoo"){var u=(this.settings.units=="metric")?"c":"f";var parameters={};parameters.q="select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='"+location+"') AND u='"+u+"'";parameters.env="store://datatables.org/alltableswithkeys";parameters.format="json";params.push(parameters)}
5var requests=[];for(var i=0;i<apiurls[this.settings.api].length;i++){requests.push($.get(apiurls[this.settings.api][i],params[i]))}
6$.when.apply(this,requests).done(function(){var args=Array.prototype.slice.call(arguments);if(requests.length>1){args=args.map(function(val){return val[0]})}else{args=args[0]}
7if(that.settings.api=="openweathermap"&&!(args[0].cod=="200"&&args[1].cod=="200")){console.log("Error interacting with the openweathermap api see error object below for details:");console.log(args);promise.reject(args,that)}else if(that.settings.api=="yahoo"&&(args.query.count==0||args.query.results.channel.description=="Yahoo! Weather Error")){console.log("Error interacting with the yahoo api see error object below for details:");console.log(args);promise.reject(args,that)}else{var weather=datamapper(args,that.settings);that._weather=weather;$.data(that.element,"weather",weather);promise.resolve(weather,that)}}).fail(function(error){console.log("fail");promise.reject(error,that)});return promise},error:function(error,context){if(!context){context=this}
8if(context.settings.loadingAnimation&&context.settings.render){context.loading.remove()}
9if(context.settings.api=="openweathermap"){if(error[0].cod!="200"){error=error[0].cod+" "+error[0].message+". See console log for details."}else{error=error[1]+" See console log for details."}}else if(context.settings.api=="yahoo"){if(error.query.results){error="Error: "+error.query.results.channel.item.title+". See console log for details."}else{error="Error: no results. See console log for details."}}
10var div=$("<div/>",{"class":"flatWeatherPlugin "+context.settings.view});$("<h2/>").text("Error").appendTo(div);$("<p/>").text(error).appendTo(div);$(context.element).html(div);return $(context.element)},render:function(weather,context){if(!context){context=this;weather=this._weather}
11var degrees=context.settings.units=="metric"?"&#176;C":"&#176;F";if(context.settings.loadingAnimation&&context.settings.render){context.loading.remove()}
12var div=$("<div/>",{"class":"flatWeatherPlugin "+context.settings.view});if(context.settings.displayCityNameOnly){$("<h2/>").text(weather.city).appendTo(div)}else{$("<h2/>").text(weather.location).appendTo(div)}
13if(context.settings.view!="forecast"){var today=$("<div/>",{"class":"wiToday"});var iconGroup=$("<div/>",{"class":"wiIconGroup"});$("<div/>",{"class":"wi "+"wi"+weather.today.code}).appendTo(iconGroup);$("<p/>",{"class":"wiText"}).text(weather.today.desc).appendTo(iconGroup);iconGroup.appendTo(today);$("<p/>",{"class":"wiTemperature"}).html(weather.today.temp.now+"<sup>"+degrees+"</sup>").appendTo(today);today.appendTo(div)}
14if(context.settings.view!="simple"){var detail=$("<div/>",{"class":"wiDetail"});if(context.settings.view=="partial"){$("<p/>",{"class":"wiDay"}).text(weather.today.day).appendTo(today)}
15if(context.settings.view!="partial"){if(context.settings.view!="today"){$("<p/>",{"class":"wiDay"}).text(weather.today.day).appendTo(detail)}
16var astro=$("<ul/>",{"class":"astronomy"}).appendTo(detail);$("<li/>",{"class":"wi sunrise"}).text(weather.today.sunrise).appendTo(astro);$("<li/>",{"class":"wi sunset"}).text(weather.today.sunset).appendTo(astro);var temp=$("<ul/>",{"class":"temp"}).appendTo(detail);$("<li/>").html("Max : "+weather.today.temp.max+"<sup>"+degrees+"</sup>").appendTo(temp);$("<li/>").html("Min : "+weather.today.temp.min+"<sup>"+degrees+"</sup>").appendTo(temp);var atmo=$("<ul/>",{"class":"atmosphere"}).appendTo(detail);$("<li/>",{"class":"wi humidity"}).text(weather.today.humidity).appendTo(atmo);$("<li/>",{"class":"wi pressure"}).text(weather.today.pressure).appendTo(atmo);$("<li/>",{"class":"wi wind"}).text(formatWind(weather.today.wind.speed,weather.today.wind.deg,context.settings.units)).appendTo(atmo);detail.appendTo(today)}
17if(context.settings.view!="today"||context.settings.view=="forecast"){var forecast=$("<ul/>",{"class":"wiForecasts"});var startingIndex=(context.settings.view=="forecast")?0:1;for(var i=startingIndex;i<weather.forecast.length;i++){var day=$("<li/>",{"class":"wiDay"}).html("<span>"+weather.forecast[i].day+"</span>").appendTo(forecast);var sub=$("<ul/>",{"class":"wiForecast"}).appendTo(day);$("<li/>",{"class":"wi "+"wi"+weather.forecast[i].code}).appendTo(sub);$("<li/>",{"class":"wiMin"}).html(weather.forecast[i].temp.min+"<sup>"+degrees+"</sup>").appendTo(sub);$("<li/>",{"class":"wiMax"}).html(weather.forecast[i].temp.max+"<sup>"+degrees+"</sup>").appendTo(sub)}
18forecast.appendTo(div)}}
19$(context.element).html(div);return $(context.element)}});$.fn[pluginName]=function(options,args){if($.isFunction(Plugin.prototype[options])){return this.data("plugin_"+pluginName)[options](args)}
20return this.each(function(){if(!$.data(this,"plugin_"+pluginName)){var plugin=new Plugin(this,options);return $.data(this,"plugin_"+pluginName,plugin)}})};function datamapper(input,settings){var out={};if(settings.api=="openweathermap"){if(input[0].name!=""){out.location=input[0].name+", "+input[0].sys.country;out.city=input[0].name}else if(input[1].city.name!=""){out.location=input[1].city.name+", "+input[1].city.country;out.city=input[1].city.name}else{out.location=settings.location+", "+settings.country;out.city=settings.location}
21out.today={};out.today.temp={};out.today.temp.now=Math.round(input[0].main.temp);out.today.temp.min=Math.round(input[0].main.temp_min);out.today.temp.max=Math.round(input[0].main.temp_max);out.today.desc=input[0].weather[0].description.capitalize();out.today.code=input[0].weather[0].id;out.today.wind=input[0].wind;out.today.humidity=input[0].main.humidity;out.today.pressure=input[0].main.pressure;out.today.sunrise=epochToHours(input[0].sys.sunrise);out.today.sunset=epochToHours(input[0].sys.sunset);out.today.day=getDayString(new Date());out.forecast=[];for(var i=0;i<settings.forecast;i++){var forecast={};forecast.day=getDayString(new Date(input[1].list[i].dt*1000));forecast.code=input[1].list[i].weather[0].id;forecast.desc=input[1].list[i].weather[0].description.capitalize();forecast.temp={max:Math.round(input[1].list[i].temp.max),min:Math.round(input[1].list[i].temp.min)}
22out.forecast.push(forecast)}}else if(settings.api=="yahoo"){var codes={0:"900",1:"901",2:"902",3:"212",4:"200",5:"616",6:"612",7:"611",8:"511",9:"301",10:"511",11:"521",12:"521",13:"600",14:"615",15:"601",16:"601",17:"906",18:"611",19:"761",20:"74
221",21:"721",22:"711",23:"956",24:"954",25:"903",26:"802",27:"802",28:"802",29:"802",30:"802",31:"800",32:"800",33:"951",34:"951",35:"906",36:"904",37:"210",38:"210",39:"210",40:"521",41:"602",42:"621",43:"602",44:"802",45:"201",46:"621",47:"210",3200:"951",}
23input=input.query.results.channel;out.location=input.location.city+", "+input.location.country;out.city=input.location.city;out.today={};out.today.temp={};out.today.temp.now=Math.round(input.item.condition.temp);out.today.temp.min=Math.round(input.item.forecast[0].low);out.today.temp.max=Math.round(input.item.forecast[0].high);out.today.desc=input.item.condition.text.capitalize();out.today.code=codes[input.item.condition.code];out.today.wind={};out.today.wind.speed=input.wind.speed;out.today.wind.deg=input.wind.direction;out.today.humidity=input.atmosphere.humidity;out.today.pressure=input.atmosphere.pressure;out.today.sunrise=input.astronomy.sunrise.toUpperCase();out.today.sunset=input.astronomy.sunset.toUpperCase();out.today.day=getDayString(new Date());out.forecast=[];for(var i=0;i<settings.forecast;i++){var forecast={};forecast.day=getDayString(new Date(input.item.forecast[i].date));forecast.code=codes[input.item.forecast[i].code];forecast.desc=input.item.forecast[i].text.capitalize();forecast.temp={max:Math.round(input.item.forecast[i].high),min:Math.round(input.item.forecast[i].low)}
24out.forecast.push(forecast)}}
25return out};String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)};function getDayString(date){return['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'][date.getDay()]};function epochToHours(date){date=new Date(date*1000);var hours=date.getHours();var minutes=date.getMinutes();var ampm=hours>=12?'PM':'AM';hours=hours%12;hours=hours?hours:12;minutes=minutes<10?'0'+minutes:minutes;var strTime=hours+':'+minutes+' '+ampm;return strTime};function formatWind(speed,degrees,units){var wd=degrees;if((wd>=0&&wd<=11.25)||(wd>348.75&&wd<=360)){wd="N"}else if(wd>11.25&&wd<=33.75){wd="NNE"}else if(wd>33.75&&wd<=56.25){wd="NE"}else if(wd>56.25&&wd<=78.75){wd="ENE"}else if(wd>78.75&&wd<=101.25){wd="E"}else if(wd>101.25&&wd<=123.75){wd="ESE"}else if(wd>123.75&&wd<=146.25){wd="SE"}else if(wd>146.25&&wd<=168.75){wd="SSE"}else if(wd>168.75&&wd<=191.25){wd="S"}else if(wd>191.25&&wd<=213.75){wd="SSW"}else if(wd>213.75&&wd<=236.25){wd="SW"}else if(wd>236.25&&wd<=258.75){wd="WSW"}else if(wd>258.75&&wd<=281.25){wd="W"}else if(wd>281.25&&wd<=303.75){wd="WNW"}else if(wd>303.75&&wd<=326.25){wd="NW"}else if(wd>326.25&&wd<=348.75){wd="NNW"}
26var speedUnits=(units=="metric")?"km/h":"mph";return wd+" "+speed+" "+speedUnits}})(jQuery,window,document)

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.