var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opens = _____WB$wombat$assign$function_____("opens"); jQuery( function ( $ ) { 'use strict'; /* ----------------------------------------- Weather ----------------------------------------- */ var $weather = $( '.theme-weather' ); $weather.each( function () { var $this = $( this ); var $parent = $this.parent(); var locationId = $this.data( 'location-id' ); var unit = $this.data( 'unit' ); var units = $this.data( 'units' ); var $temp = $this.find( '.theme-weather-temp' ); var $location = $this.find( '.theme-weather-location' ); if ( ! units || ! locationId || ! unit ) { if ( ! $location.text() ) { $parent.hide(); } console.warn( 'Theme weather module :: No temperature unit or location id found.' ); return; } $.ajax( { url: public_opinion_plugin_vars.ajaxurl, data: { action: 'public_opinion_plugin_get_weather_conditions', weather_nonce: public_opinion_plugin_vars.weather_nonce, location_id: locationId, units: units, }, dataType: 'json', cache: false, } ).done( function ( response ) { if ( ! response.error ) { var temperature = response.data.main.temp; var temperatureString = Math.round( temperature ) + ' °' + unit; $temp.text( temperatureString ); $location.text( response.data.name + ', ' + response.data.sys.country ); $this.show(); } else { if ( ! $location.text() ) { $parent.hide(); } console.error( 'Theme weather module error :: ', response.data.errors ); } } ).fail( function ( response ) { if ( ! $location.text() ) { $parent.hide(); } console.error( 'Theme weather module :: ', response.responseText ); } ); } ); } ); }