https://www.tricityrecordnm.com/wp-content/themes/ballantine-news-theme/js/weather.js?ver=1786834150
1/** 2 * Header weather widget. 3 * 4 * The header HTML is intentionally cache-safe: LiteSpeed/Cloudflare may serve 5 * cached page markup with the fallback "--°F" value. This script hydrates the 6 * displayed temperature after load from a small public REST endpoint that reads 7 * the same cached weather payload as the weather page. 8 */ 9jQuery(document).ready(function ($) { 10 11 function updateWeatherIcon(condition) { 12 const lc = (condition || '').toLowerCase(); 13 let iconClass = 'fa-cloud-sun'; 14 15 if (lc.includes('tornado')) iconClass = 'fa-tornado'; 16 else if (lc.includes('thunder') || lc.includes('storm')) iconClass = 'fa-bolt'; 17 else if (lc.includes('snow') || lc.includes('blizzard')) iconClass = 'fa-snowflake'; 18 else if (lc.includes('sleet') || lc.includes('freezing')) iconClass = 'fa-icicles'; 19 else if (lc.includes('rain') || lc.includes('shower') || lc.includes('drizzle')) iconClass = 'fa-cloud-rain'; 20 else if (lc.includes('fog') || lc.includes('mist') || lc.includes('haze')) iconClass = 'fa-smog'; 21 else if (lc.includes('overcast') || lc.includes('cloudy')) iconClass = 'fa-cloud'; 22 else if (lc.includes('partly')) iconClass = 'fa-cloud-sun'; 23 else if (lc.includes('sunny') || lc.includes('clear')) iconClass = 'fa-sun'; 24 25 $('#weather-icon').removeClass().addClass('fas ' + iconClass + ' fs-5'); 26 $('#weather-icon-mobile').removeClass().addClass('fas ' + iconClass); 27 $('#weather-icon-mobile-nav').removeClass().addClass('fas ' + iconClass); 28 } 29
30 function applyWeather(data) { 31 if (!data || typeof data.temp === 'undefined' || data.temp === null || data.temp === '') return; 32 33 const temp = parseInt(data.temp, 10); 34 if (Number.isNaN(temp)) return; 35 36 $('#weather-temp').html(temp + '°F'); 37 $('#weather-temp-mobile').html(temp + '°F — Durango Weather'); 38 $('#weather-temp-mobile-nav').html(temp + '°F'); 39 updateWeatherIcon(data.condition || ''); 40 $('#weather-condition').text(data.condition || ''); 41 } 42 43 function getWeatherViaRest() { 44 if (!window.heraldAjax || !window.heraldAjax.weatherRestUrl || !window.fetch) { 45 return $.Deferred().reject().promise(); 46 } 47 48 return fetch(window.heraldAjax.weatherRestUrl, { 49 method: 'GET', 50 credentials: 'same-origin', 51 cache: 'no-store', 52 headers: { 53 'Accept': 'application/json' 54 } 55 }) 56 .then(function (response) { 57 if (!response.ok) throw new Error('Weather endpoint unavailable'); 58 return response.json(); 59 }) 60 .then(function (data) {
61 applyWeather(data); 62 return data; 63 }); 64 } 65 66 function getWeatherViaAjaxFallback() { 67 if (!window.heraldAjax || !window.heraldAjax.url) return; 68 69 $.post(window.heraldAjax.url, { 70 action: 'herald_header_weather', 71 nonce: window.heraldAjax.nonce, 72 }) 73 .done(function (res) { 74 if (res.success && res.data) { 75 applyWeather(res.data); 76 } 77 }); 78 } 79 80 function getWeather() { 81 const restRequest = getWeatherViaRest(); 82 83 if (restRequest && typeof restRequest.catch === 'function') { 84 restRequest.catch(getWeatherViaAjaxFallback); 85 } else if (restRequest && typeof restRequest.fail === 'function') { 86 restRequest.fail(getWeatherViaAjaxFallback); 87 } else { 88 getWeatherViaAjaxFallback(); 89 } 90 } 91 92 if ($('#weather-temp').length || $('#weather-temp-mobile-nav').length) { 93 getWeather(); 94 // Refresh every 30 min to pick up a newer weather transient. 95 setInterval(getWeather, 30 * 60 * 1000); 96 } 97 98 // Extra location cards are server-rendered via PHP on page load using 99 // herald_get_full_weather_by_coords() with the weather transients, so no 100 // client-side fetch is needed here. 101 102});
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.