
var weatherLongTerm={click:function(){$('.widget-link-button-big a')[0].click();},init:function(){$('.widget-title')[0].addEventListener("click",weatherLongTerm.click);if($('.widget-weather-long-term .async-content').length>0){$('.widget-weather-long-term .async-content')[0].addEventListener("click",weatherLongTerm.click);var blues=$('.widget-weather-long-term table tr:nth-child(4) td div.blue:last-child');for(var i=0;i<blues.length;i++){drop=document.createElement('i');drop.className+='fa fa-tint blue';drop.title="Neerslag";blues[i].prepend(drop);}
weatherLongTerm.setContentHeight();weatherLongTerm.checkTitleHeight();}},setContentHeight:function(){if($('.widget-weather-long-term .widget-warning > div')[0]===undefined){$('.widget-weather-long-term .widget-warning > div').hide();$('.async-content').removeClass('warning');}
else{$('.widget-weather-long-term .widget-warning > div').show();$('.async-content').addClass('warning');}},checkTitleHeight:function(){if($('.widget-title').height()>52){$('.widget-weather-long-term').addClass('large');$('.widget-warning').addClass('large');}else{$('.widget-weather-long-term').removeClass('large');$('.widget-warning').removeClass('large');}}};$(weatherLongTerm.init);var widgetWarning={warning:function(data){if(data.Active){$(data.Elements).each(function(i){if(this.Color===data.Color){widgetWarning.add(this.Title,data.Color);}});}},add:function(text,color){url="https://www.weerplaza.nl/waarschuwing/";if($('.widget-warning .widget-warning-block').length<1){$('.widget-warning').append('<a target="_blank" href="'+url+'"><div class="widget-warning-block bg-'+color+' clearfix"></div></a>');}
var warning=$('.widget-warning .widget-warning-block');if($('.widget-warning .widget-warning-block .fa-warning').length<1){warning.append('<i class="fa fa-warning"></i>');}
if($('.widget-warning .widget-warning-block .fa-chevron-right').length<1){warning.append('<i class="fa fa-chevron-right"></i>');}
if($('.widget-warning .widget-warning-block .text').length<1){warning.append('<div class="text truncate">'+text+'</div>');}else{var title=$('.widget-warning .widget-warning-block .text');title[0].innerHTML=widgetWarning.mergeTitles(title[0].innerHTML,text);}},mergeTitles:function(currentTitle,extraTitle){var extra=extraTitle.split(':')[1];return currentTitle+','+extra;}};var now={init:function(){now.setLink();var fnClick=function(){$('.widget-weather-now .btn.large')[0].click();};$('.widget-title').on("click",fnClick);$('.widget-weather-now .weather').on("click",fnClick);now.checkTitleHeight();now.setButtonText();if($('.widget-weather-now').width()){$('.widget-weather-now')[0].classList.add('xs');}
now.setContentHeight();},checkTitleHeight:function(){if($('.widget-weather-now .widget-title').height()>52){$('.location-widget').addClass('large');var title=$('.widget-title h3')[0].innerText;var substring="Nu in ";if(title.includes(substring)){title=title.replace(substring,"");$('.widget-title h3')[0].innerText=title;if($('.widget-weather-now .widget-title').height()>52){$('.widget-title').addClass('large');}}
else{$('.widget-weather-now .widget-title h3').css({"font-size":"1.5rem","max-width":"63%","overflow":"hidden"});}}else{$('.location-widget').removeClass('large');}},setLink:function(){var button=$('.widget-weather-now .btn.large')[0];if(button){button.setAttribute('target',siteId===3?'_parent':'_blank');}},setButtonText:function(){if(typeof geoName!=='undefined'&&name!==geoName){$('.location-widget .btn-more a')[0].text="Uitgebreid weer "+name;}},setContentHeight:function(){if(typeof country!=='undefined'){var green=$('.widget-weather-now .warning-bg.bg-green').length;if(green>0&&country==="NL"||green===0&&country!=="NL"){$('.location-widget').addClass('no-warning');}
else{$('.location-widget').removeClass('no-warning');}}}};$(now.init);var locationWidget={geoId:0,countryCode:'',init:function(id,countryCode){locationWidget.geoId=id;locationWidget.countryCode=countryCode;locationWidget.load();},load:function(){$.ajax({url:'/api/meteo/homewidget/',data:{'geoId':locationWidget.geoId},type:'GET',dataType:'json',success:locationWidget.update});},update:function(data){$('.splash-text').html(data.Splash.Text);$('.splash-bg').addClass('bg-'+data.Splash.Color.toLowerCase()).removeClass('hide');$('.flash-text').html(data.Flash.Text);$('.flash-bg').addClass('bg-'+data.Flash.Color.toLowerCase()).removeClass('hide');var elType=$('.location-widget .weather .type').empty();if(data.Obs.WXCO_EXTENDED){elType.append('<div class="geo-'+locationWidget.geoId+' wx wx-b60" style="background-image: url(/Content/Images/WeatherExtended/svg/lb/'+data.Obs.WXCO_Extended+'_LB.svg)" title="'+data.Obs.WXCO_EXTENDED_TEXT+'"></div>');}else{if(data.Obs.WXCO){elType.append('<div class="geo-'+locationWidget.geoId+' wx wx-b60" style="background-image: url(/Content/Images/Weather/b60x60/'+data.Obs.WXCO+'.png)" title="'+data.Obs.WXCO_TEXT+'"></div>');}}
if(data.Obs.TTTT!==null){elType.append('<span class="geo-'+locationWidget.geoId+' temp">'+parseInt(data.Obs.TTTT)+'°</span>');}
var elRating=$('.location-widget .rating').empty();if(data.Obs.WXNUM){elRating.append('<span class="weather-rating large r-'+data.Obs.WXNUM+'" onclick="modal.show(\'#weather-rating\')">'+data.Obs.WXNUM+'</span>');elRating.append('<a href="javascript:modal.show(\'#weather-rating\')">Weercijfer</a>');}
if(data.Obs.RRRR){$('.location-widget .rain').html('Neerslag: <em>'+data.Obs.RRRR+' mm</em>').show();}else{$('.location-widget .rain').hide();}
if(data.Obs.RHRH){$('.location-widget .humidity').html('Vochtigheid: <em>'+data.Obs.RHRH+'%</em>').show();}else{$('.location-widget .humidity').hide();}
if(data.Obs.DDDD&&data.Obs.FFFF){$('.location-widget .wind').html('Wind: <em>'+data.Obs.DDDD+' '+data.Obs.FFFF+'</em>').show();}else{$('.location-widget .wind').hide();}
if(data.Obs.PPPP>0){$('.location-widget .pressure').html('Druk: <em>'+data.Obs.PPPP+' hPa</em>');}else{$('.location-widget .pressure').html();}
if(typeof newsWarning!=='undefined'){if(locationWidget.countryCode==='NL'){$('.warning-text').html(data.Warning.Title);$('.warning-bg').addClass(' bg-'+data.Warning.Color.toLowerCase()).removeClass('hide');}}
if(data.MeteoWarning!==null){var warning=$('.location-widget .meteo-warning-block');warning.html('<a target="'+target+'" href="/waarschuwing/" class="btn warning warning-small warning-bg bg-'+data.MeteoWarning.Color+'"></a>');var warningLink=$('.location-widget .meteo-warning-block a');warningLink.append('<div class="icon"><i class="fa fa-warning"></i></div>');warningLink.append('<span>WAARSCHUWING <div class="warning-text truncate">'+data.MeteoWarning.Title+'</div></span>');warningLink.append('<i class="fa fa-chevron-right"></i>');}else{$('.location-widget .meteo-warning-block').hide();}}};var radarWidget={init:function(){var zoom=6;var lat=50;var lon=50;var loc=null;if(wpLocation.city){lat=wpLocation.city.Lat;lon=wpLocation.city.Lon;loc=wpLocation.city;}else if(wpLocation.country){zoom=wpLocation.country.ZoomLevel-1.5;lat=wpLocation.country.Lat;lon=wpLocation.country.Lon;loc=wpLocation.country;}else if(wpLocation.continent){zoom=wpLocation.continent.ZoomLevel-1.5;lat=wpLocation.continent.Lat;lon=wpLocation.continent.Lon;loc=wpLocation.continent;}
var options={useHD:true,enablePan:false,enableZoom:false,minZoom:zoom,timeLabels:false};radarWidget.setContentHeight();var mapEl=$('.radar-widget .map');var map=wpMap.create(mapEl,mapEl.height(),[lat,lon],zoom,options);map.animation('forecast',1,false,null,false,null,null,null);if(wpLocation.city){map.geo(wpLocation.city,0,true,false,false);}
var linkRain=wpLocation.url(loc,'regenradar','');$('.radar-widget a').attr('href',linkRain);},setContentHeight:function(){if($('.location-widget .warning-bg').length>0&&$('.location-widget .warning-bg.bg-green').length===0){$('.radar-widget').addClass('warning');}
else{$('.radar-widget').removeClass('warning');}}};var rainWidget={graph:function(ts){var values=[];$('.rain-timeline .graph > svg').remove();if(ts.length>0){if(ts[0].precipAmount===null){console.warn('[rainWidget] No precipAmount found',ts);$('.rain-widget .rain-timeline').addClass('hide');return;}
$(ts).each(function(i){values.push(this.precipAmount);});var max=Math.ceil(Math.max.apply(null,values));if(max===0)max=1;if(max>1&&max<3)max=3;if(max>5&&max<10)max=10;var points=[];$(values).each(function(i){points.push({x:i*10,y:parseInt(60-60/max*this)});});var svgFunc=d3.svg.area().interpolate('monotone').x(function(d){return d.x;}).y0(60).y1(function(d){return d.y;});var svg='';svg+='<svg viewBox="0 0 '+(points.length-1)*10+' 60" preserveAspectRatio="none">';svg+='  <path d="'+svgFunc(points)+'" vector-effect="non-scaling-stroke" fill="#1DB3E6" />';svg+='</svg>';$('.rain-timeline .graph').append(svg);$('.rain-timeline .graph .label').hide();if(max<=5)$('.rain-timeline .graph .label.label-light').show().css('top',100-100/max*1+'%');if(max>=3)$('.rain-timeline .graph .label.label-moderate').show().css('top',100-100/max*3+'%');if(max>=10)$('.rain-timeline .graph .label.label-high').show().css('top',100-100/max*10+'%');$('.rain-widget .rain-timeline').removeClass('hide');}else{$('.rain-widget .rain-timeline').addClass('hide');}}};var locationToday={init:function(){locationToday.checkTitleHeight();locationToday.setContentHeight();},setContentHeight:function(){if($('.widget-weather-today .widget-warning > a')[0]===undefined){$('.widget-weather-today .widget-warning > a').hide();$('.dayparts').removeClass('warning');$('.widget-link-button-big').removeClass('warning');}
else{$('.widget-weather-today .widget-warning > a').show();$('.dayparts').addClass('warning');$('.widget-link-button-big').addClass('warning');}},checkTitleHeight:function(){var title="";var substring="";if($('.widget-title').height()>52){$('.widget-weather-today').addClass('large');if($('.widget-weather-today .warning-block')[0]!==undefined){$('.widget-warning').addClass('large');}
title=$('.widget-title h3')[0].innerText;substring="Weerbericht ";title=title.replace(substring,"");$('.widget-title h3')[0].innerText=title;}else{$('.widget-weather-today').removeClass('large');$('.widget-warning').removeClass('large');}
if($('.widget-title h3').height()>=102){title=$('.widget-title h3')[0].innerText;substring="Weerbericht ";title=title.replace(substring,"");$('.widget-title h3')[0].innerText=title;}}};$(locationToday.init);var wpBannerSnippet={log:function(id,status,extra){var statusDiv=$('#'+id).parent().find('.logging');if(statusDiv.length>0){var now=new Date();var time=('00'+now.getHours()).substr(-2)+':'+('00'+now.getMinutes()).substr(-2)+':'+('00'+now.getSeconds()).substr(-2);var item=$('<div class="item"></div>');item.append('<div class="time">'+time+'</div>');item.append('<div class="status">'+status+'</div>');if(extra){item.append('<div class="extra">'+extra+'</div>');}
item.appendTo(statusDiv);console.log('[AD] '+id,status);}}}
if(typeof(googletag)!='undefined'){googletag.cmd.push(function(){googletag.pubads().addEventListener('slotRenderEnded',function(event){var bannerDivId=event.slot.getSlotElementId();var details='';Object.keys(event).sort().forEach(function(key){var val=event[key];if(typeof(val)!=='object'||Array.isArray(val)){details+='<div><b>'+key+':</b> '+val+'<div>';}});wpBannerSnippet.log(bannerDivId,'rendered',details);});});}