(function($){"use strict";$(document).ready(function(){if($.fn.lsvrPressvilleToolkitWeatherWidget){$('.lsvr-pressville-weather-widget__weather').each(function(){$(this).lsvrPressvilleToolkitWeatherWidget()})}});if(!$.fn.lsvrPressvilleToolkitWeatherWidget){$.fn.lsvrPressvilleToolkitWeatherWidget=function(){var $this=$(this),$spinner=$this.find('.lsvr-pressville-weather-widget__weather-spinner'),ajaxParams=$this.data('ajax-params')?$this.data('ajax-params'):false,forecastLength=$this.data('forecast-length')&&!isNaN($this.data('forecast-length'))?parseInt($this.data('forecast-length')):0;if(false!==ajaxParams&&'undefined'!==typeof lsvr_pressville_toolkit_ajax_weather_widget_var){jQuery.ajax({type:'post',dataType:'JSON',url:lsvr_pressville_toolkit_ajax_weather_widget_var.url,data:{action:'lsvr-pressville-toolkit-ajax-weather-widget',nonce:encodeURIComponent(lsvr_pressville_toolkit_ajax_weather_widget_var.nonce),data:ajaxParams},success:function(response){if(typeof response==='object'){if(!('error'in response)){var currentData={},forecastData=[];if('current'in response){if('name'in response.current){$this.attr('data-response-current-location',response.current.name)}if('main'in response.current&&'temp'in response.current.main){currentData.temperature=String(Math.round(response.current.main.temp))}if('wind'in response.current&&'speed'in response.current.wind){currentData.wind=Math.floor(response.current.wind.speed)}if('weather'in response.current&&$.isArray(response.current.weather)&&'icon'in response.current.weather[0]){currentData.icon=response.current.weather[0].icon}}if('forecast'in response&&'list'in response.forecast){if('city'in response.forecast&&'name'in response.forecast.city){$this.attr('data-response-forecast-location',response.forecast.city.name)}for(var i=0;i-1000){forecastData[i].temperature=tempMax}if('wind'in response.forecast.list[forecastIndex]&&'speed'in response.forecast.list[forecastIndex].wind){forecastData[i].wind=Math.floor(response.forecast.list[forecastIndex].wind.speed)}if('weather'in response.forecast.list[forecastIndex]&&$.isArray(response.forecast.list[forecastIndex].weather)&&'icon'in response.forecast.list[forecastIndex].weather[0]){forecastData[i].icon=response.forecast.list[forecastIndex].weather[0].icon}}}generateHtml(currentData,forecastData)}else{$this.attr('data-response-error',response.error);$this.slideUp(200)}}else{$this.slideUp(200)}},error:function(){$this.slideUp(200)}})}var generateHtml=function(currentData,forecastData){var $list=$this.find('.lsvr-pressville-weather-widget__weather-list'),$current=$list.find('.lsvr-pressville-weather-widget__weather-item--current'),$forecastList=$list.find('.lsvr-pressville-weather-widget__weather-item--forecast'),iconClasses={i01d:'icon-sun',i01n:'icon-sun',i02d:'icon-cloud-sun',i02n:'icon-cloud',i03d:'icon-cloud',i03n:'icon-cloud',i04d:'icon-cloud',i04n:'icon-cloud',i09d:'icon-cloud-rain',i09n:'icon-cloud-rain',i10d:'icon-cloud-rain',i10n:'icon-cloud-rain',i11d:'icon-cloud-lightning',i11n:'icon-cloud-lightning',i13d:'icon-cloud-snow',i13n:'icon-cloud-snow',i50d:'icon-cloud-fog',i50n:'icon-cloud-fog'};if('temperature'in currentData&&'wind'in currentData&&'icon'in currentData){if('i'+currentData.icon in iconClasses){$current.find('.lsvr-pressville-weather-widget__weather-item-icon').addClass(iconClasses['i'+currentData.icon])}else{$current.find('.lsvr-pressville-weather-widget__weather-item-icon').hide()}var temperatureUnit=$current.find('.lsvr-pressville-weather-widget__weather-item-temperature').text().trim();$current.find('.lsvr-pressville-weather-widget__weather-item-temperature').html(currentData.temperature+temperatureUnit);var windUnit=$current.find('.lsvr-pressville-weather-widget__weather-item-wind').text().trim();$current.find('.lsvr-pressville-weather-widget__weather-item-wind').html(currentData.wind+' '+windUnit)}if(forecastData.length>0){for(var i=0;i