1/** 2 * 3 **/ 4 5(function($){ 6 7 $.fn.meteo = function(uid, fn) { 8 9 var days = ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi']; 10 var months = ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre']; 11 12 var code = new Array(); 13 code[0] = "Ciel dégagé"; 14 code[1] = "Quelques nuages"; 15 code[2] = "Partiellement couvert"; 16 code[3] = "Ciel couvert"; 17 code[45] = "Brouillard"; 18 code[48] = "Brouillard givrant"; 19 code[51] = "Bruine faible"; 20 code[53] = "Bruine"; 21 code[55] = "Bruine intense"; 22 code[56] = "Bruine verglaçante modérée"; 23 code[57] = "Bruine verglaçante intense"; 24 code[61] = "Pluie faible"; 25 code[63] = "Pluie modérée"; 26 code[65] = "Pluie intense"; 27 code[66] = "Pluie verglaçante modérée"; 28 code[67] = "Pluie verglaçante intense"; 29 code[71] = "Neige faible"; 30 code[73] = "Neige modérée"; 31 code[75] = "Neige intense"; 32 code[77] = "Neige fine"; 33 code[80] = "Averses légères"; 34 code[81] = "Averses modérées"; 35 code[82] = "Averses violentes"; 36 code[85] = "Averses de neige"; 37 code[86] = "Averses de neige intenses"; 38 code[95] = "Orage"; 39 code[96] = "Orage et grêle"; 40 code[99] = "Orage et grêle intense"; 41 42 var color = new Array(); 43 color[0] = ["#EF9400","#333"]; 44 color[1] = ["#55C7E2","#333"]; 45 color[2] = ["#55C7E2","#333"]; 46 color[3] = ["#697A8E","#FFF"]; 47 color[45] = ["#A9AFB6","#333"]; 48 color[48] = ["#A9AFB6","#333"]; 49 color[51] = ["#87A8BF","#333"]; 50 color[53] = ["#87A8BF","#333"]; 51 color[55] = ["#4C708A","#FFF"]; 52 color[56] = ["#4C708A","#FFF"]; 53 color[57] = ["#4C708A","#FFF"]; 54 color[61] = ["#4C708A","#FFF"]; 55 color[63] = ["#4C708A","#FFF"]; 56 color[65] = ["#4C708A","#FFF"]; 57 color[66] = ["#475D6C","#FFF"]; 58 color[67] = ["#475D6C","#FFF"]; 59 color[71] = ["#D8D8D8","#333"]; 60 color[73] = ["#D8D8D8","#333"]; 61 color[75] = ["#D8D8D8","#333"]; 62 color[77] = ["#D8D8D8","#333"]; 63 color[80] = ["#4C708A","#FFF"]; 64 color[81] = ["#4C708A","#FFF"]; 65 color[82] = ["#4C708A","#FFF"]; 66 color[85] = ["#D8D8D8","#333"]; 67 color[86] = ["#D8D8D8","#333"]; 68 color[95] = ["#333","#FFF"]; 69 color[96] = ["#333","#FFF"]; 70 color[99] = ["#333","#FFF"]; 71 72 return this.each(function(i, e) { 73 var $e = $(e); 74 75 // Send 1st request 76 $.ajax({ 77 type: 'GET', 78 url: '?MeteoUID='+uid, 79 dataType: 'json', 80 success: function(data) { 81 //console.log(data); 82 //console.log("cacheHit : "+data.cacheHit); 83 //console.log(uid); 84 if (data) { 85 if (data.dayPart < 1 || data.dayPart > 4) { 86 _error(e); 87 } else { 88 //console.log(data.daily); 89 //console.log(data.hourly); 90 _today(e,data.jours[0],data.latitude,data.longitude); 91 _nextHours(e,data.heures); 92 _nextDays(e,[data.jours[1],data.jours[2],data.jours[3],data.jours[4]]); 93 return true; 94 } 95 } else { 96 _error(e); 97 } 98 }, 99 error: function() { 100 _error(e); 101 } 102 }); 103 104 var _error = function(e) { 105 var $e = $(e); 106 var msg = "<div class='alert alert-warning'><p>Désolé, le service Open-Meteo n'est actuellement pas en mesure de fournir les données météo.<br>Veuillez nous excuser pour ce désagrément. Nous vous invitons à actualiser la page ou à consulter celle-ci ultérieurement.</p></div>"; 107 $e.append(msg); 108 return true; 109 } 110 111 var _today = function(e,today,latitude,longitude) { 112 var $e = $(e); 113 var isHeader = e.getElementsByTagName("header").length; 114 var iconStyle='wi-wmorvvn-day-'+today.code; 115 var html='<div class="row"><h3 class="d-lg-none">La météo du jour</h3><div class="today col-12 col-lg-4"><div class="todayItem" style="background-color:'+color[today.code][0]+';color:'+color[today.code][1]+';"></div>'; 116 if(isHeader==0)$e.prepend(html); 117 else $(e.getElementsByTagName("header")[0]).after(html); 118 var time = new Date(today.time); 119 var year = time.getFullYear(); 120 var month = months[time.getMonth()]; 121 var day = days[time.getDay()]; 122 var date = time.getDate(); 123 var html=''; 124 html+='<div class="col-12 date">'+day+' '+date+' '+month+' '+year+'</div>'; 125 html+='<div class="row main">'; 126 html+='<div class="col-4 icon '+iconStyle+'"></div>'; 127 html+='<div class="col-8 row">'; 128 html+='<div class="col-12 temp"><big><b>'+parseInt(today.temperatureMin)+'</b></big> à <big><b>'+parseInt(today.temperatureMax)+'</b></big>°C</div>'; 129 html+='</div>'; 130 html+='</div>'; 131 html+='<div class="cond col-12">'+code[today.code]+'</div>'; 132 html+='<div class="row">'; 133 html+='<div class="col-12 humidity"><i>Risque de pluie : </i><b>'+today.precipitation+'</b>%</div>'; 134 var wd = today.windDirection; 135 if(typeof wd === "undefined") { 136 wd=""; 137 } else { 138 if(wd>=337.5&&wd<=360){wd='<i class="wi wi-direction wi-direction-up"></i>'}; 139 if(wd>=0&&wd<22.5){wd='<i class="wi wi-direction wi-direction-up"></i>'}; 140 if(wd>=22.5&&wd<67.5){wd='<i class="wi wi-direction wi-direction-up-right"></i>'}; 141 if(wd>=67.5&&wd<112.5){wd='<i class="wi wi-direction wi-direction-right"></i>'}; 142 if(wd>=112.5&&wd<157.5){wd='<i class="wi wi-direction wi-direction-down-right"></i>'}; 143 if(wd>=157.5&&wd<202.5){wd='<i class="wi wi-direction wi-direction-down"></i>'}; 144 if(wd>=202.5&&wd<247.5){wd='<i class="wi wi-direction wi-direction-down-left"></i>'}; 145 if(wd>=247.5&&wd<292.5){wd='<i class="wi wi-direction wi-direction-left"></i>'}; 146 if(wd>=292.5&&wd<337.5){wd='<i class="wi wi-direction wi-direction-up-left"></i>'}; 147 } 148 html+='<div class="col-12 wind"><i>Vent : </i> '+wd+' <b>'+parseInt(today.windSpeed)+'</b>km/h</div>'; 149 var sunrise = new Date(today.sunrise); 150 var sunset = new Date(today.sunset); 151 html+='<div class="sunrise col-6"><i>Lever : </i><b>'+sunrise.getHours()+'</b>h<b>'+(sunrise.getMinutes()<10?'0':'')+sunrise.getMinutes()+'</b></div>'; 152 html+='<div class="sunset col-6"><i>Coucher : </i><b>'+sunset.getHours()+'</b>h<b>'+(sunset.getMinutes()<10?'0':'')+sunset.getMinutes()+'</b></div>'; 153 html+='<div class="latitude col-6"><i>Lat : </i><b>'+latitude+'</b></div>'; 154 html+='<div class="longitude col-6"><i>Long : </i><b>'+longitude+'</b></div>'; 155 html+='</div>'; 156 $e.find(".today").find(".todayItem").append(html); 157 }; 158 159 var _nextHours = function(e,hours) { 160 var $e = $(e); 161 var html='<div class="col-12 col-lg-8 nextHours"><h3 class="d-lg-none noPad">Dans les prochaines heures</h3><div class="row forecastHours"></div></div></div>'; 162 $e.find(".today").after(html); 163 for (var i=0; i<hours.length; i++) { 164 var blocStyle='background-color:'+color[hours[i].code][0]+';color:'+color[hours[i].code][1]+';'; 165 var iconStyle='wi-wmorvvn-day-'+hours[i].code; 166 if(hours[i].isDay == 0) { 167 blocStyle='background-color:#393939;
167color:#FFF;'; 168 var iconStyle='wi-wmorvvn-night-'+hours[i].code; 169 } 170 var html = '<div class="weatherItem col-12 col-sm-6"><div class="weatherItemMeteo" style="'+blocStyle+'">'; 171 var time = new Date(hours[i].time); 172 var month = months[time.getMonth()]; 173 var day = days[time.getDay()]; 174 var date = time.getDate(); 175 var hour = time.getHours(); 176 html+='<div class="time col-12">'+day+' '+date+' '+month+'<div class="hour">'+hour+'h</div></div>'; 177 html+='<div class="row">'; 178 html+='<div class="col-4 icon '+iconStyle+'"></div>'; 179 html+='<div class="col-8">'; 180 html+='<div class="cond">'+code[hours[i].code]+'</div>'; 181 html+='<div><i>Température : </i><b>'+parseInt(hours[i].temperature)+'</b>°C</div>'; 182 html+='<div class="clouds"><i>Nuages : </i>'; 183 if(hours[i].clouds<5) { html+='<i class="wi wi-cloud"></i>' } else { html+='<i class="wi wi-cloud opak"></i>' } 184 if(hours[i].clouds<20) { html+='<i class="wi wi-cloud"></i>' } else { html+='<i class="wi wi-cloud opak"></i>' } 185 if(hours[i].clouds<40) { html+='<i class="wi wi-cloud"></i>' } else { html+='<i class="wi wi-cloud opak"></i>' } 186 if(hours[i].clouds<60) { html+='<i class="wi wi-cloud"></i>' } else { html+='<i class="wi wi-cloud opak"></i>' } 187 if(hours[i].clouds<80) { html+='<i class="wi wi-cloud"></i>' } else { html+='<i class="wi wi-cloud opak"></i>' } 188 html+='</div>'; 189 html+='<div><i>Risque de pluie : </i><b>'+parseInt(hours[i].precipitation)+'</b>%</div>'; 190 var wd = hours[i].windDirection; 191 if(typeof wd === "undefined") { 192 wd=""; 193 } else { 194 if(wd>=337.5&&wd<=360){wd='<i class="wi wi-direction wi-direction-up"></i>'}; 195 if(wd>=0&&wd<22.5){wd='<i class="wi wi-direction wi-direction-up"></i>'}; 196 if(wd>=22.5&&wd<67.5){wd='<i class="wi wi-direction wi-direction-up-right"></i>'}; 197 if(wd>=67.5&&wd<112.5){wd='<i class="wi wi-direction wi-direction-right"></i>'}; 198 if(wd>=112.5&&wd<157.5){wd='<i class="wi wi-direction wi-direction-down-right"></i>'}; 199 if(wd>=157.5&&wd<202.5){wd='<i class="wi wi-direction wi-direction-down"></i>'}; 200 if(wd>=202.5&&wd<247.5){wd='<i class="wi wi-direction wi-direction-down-left"></i>'}; 201 if(wd>=247.5&&wd<292.5){wd='<i class="wi wi-direction wi-direction-left"></i>'}; 202 if(wd>=292.5&&wd<337.5){wd='<i class="wi wi-direction wi-direction-up-left"></i>'}; 203 } 204 html+='<div><i>Vent : </i> '+wd+' <b>'+parseInt(hours[i].windSpeed)+'</b>km/h'; 205 html+='</div></div></div></div>'; 206 $e.find(".forecastHours").append(html); 207 } 208 }; 209 var _nextDays = function(e,nextDays) { 210 //console.log(nextDays); 211 var $e = $(e); 212 var html='<div class="col-12 nextDays"><h3 class="noPad">Dans les prochains jours</h3><div class="row forecastDays"></div></div></div>'; 213 $e.find(".nextHours").after(html); 214 for (var i=0; i<nextDays.length; i++) { 215 var blocStyle='background-color:'+color[nextDays[i].code][0]+';color:'+color[nextDays[i].code][1]+';'; 216 var iconStyle='wi-wmorvvn-day-'+nextDays[i].code; 217 var html = '<div class="weatherItem col-12 col-sm-6 col-lg-3"><div class="weatherItemMeteo" style="'+blocStyle+'">'; 218 var time = new Date(nextDays[i].time); 219 var month = months[time.getMonth()]; 220 var day = days[time.getDay()]; 221 var date = time.getDate(); 222 html+='<div class="date col-12">'+day+' '+date+' '+month+'</div>'; 223 html+='<div class="row">'; 224 html+='<div class="col-3 icon '+iconStyle+'"></div>'; 225 html+='<div class="col-9">'; 226 html+='<div class="cond">'+code[nextDays[i].code]+'</div>'; 227 html+='<div><i>Température : </i><b>'+parseInt(nextDays[i].temperatureMin)+'</b> à <b>'+parseInt(nextDays[i].temperatureMax)+'</b>°C</div>'; 228 html+='<div><i>Risque de pluie : </i><b>'+parseInt(nextDays[i].precipitation)+'</b>%</div>'; 229 var wd = nextDays[i].windDirection; 230 if(typeof wd === "undefined") { 231 wd=""; 232 } else { 233 if(wd>=337.5&&wd<=360){wd='<i class="wi wi-direction wi-direction-up"></i>'}; 234 if(wd>=0&&wd<22.5){wd='<i class="wi wi-direction wi-direction-up"></i>'}; 235 if(wd>=22.5&&wd<67.5){wd='<i class="wi wi-direction wi-direction-up-right"></i>'}; 236 if(wd>=67.5&&wd<112.5){wd='<i class="wi wi-direction wi-direction-right"></i>'}; 237 if(wd>=112.5&&wd<157.5){wd='<i class="wi wi-direction wi-direction-down-right"></i>'}; 238 if(wd>=157.5&&wd<202.5){wd='<i class="wi wi-direction wi-direction-down"></i>'}; 239 if(wd>=202.5&&wd<247.5){wd='<i class="wi wi-direction wi-direction-down-left"></i>'}; 240 if(wd>=247.5&&wd<292.5){wd='<i class="wi wi-direction wi-direction-left"></i>'}; 241 if(wd>=292.5&&wd<337.5){wd='<i class="wi wi-direction wi-direction-up-left"></i>'}; 242 } 243 html+='<div><i>Vent : </i> '+wd+' <b>'+parseInt(nextDays[i].windSpeed)+'</b>km/h</div>'; 244 var sunrise = new Date(nextDays[i].sunrise); 245 var sunset = new Date(nextDays[i].sunset); 246 html+='<div><i>Jour de : </i><b>'+sunrise.getHours()+'h'+(sunrise.getMinutes()<10?'0':'')+sunrise.getMinutes()+'</b> à <b>'+sunset.getHours()+'h'+(sunset.getMinutes()<10?'0':'')+sunset.getMinutes()+'</b></div>'; 247 html+='</div>'; 248 html+='</div></div></div>'; 249 $e.find(".forecastDays").append(html); 250 } 251 }; 252 }); 253 } 254 255})(jQuery);
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.