PageSourceSearch

https://cashbackkredittkort.com/wp-content/plugins/clima-widget/public/js/clima-widget-public.js?ver=1.0.0

js cashbackkredittkort.com collected 2026-10-09 18:27:32 UTC 8,871 bytes, 258 lines download raw bytes

1(function ($) {
2	'use strict';
3	/**
4	 * All of the code for your public-facing JavaScript source
5	 * should reside in this file.
6	 *
7	 * Note: It has been assumed you will write jQuery code here, so the
8	 * $ function reference has been prepared for usage within the scope
9	 * of this function.
10	 *
11	 * This enables you to define handlers, for when the DOM is ready:
12	 */
13	$(function () {
14		String.prototype.capitalize = function () {
15			return this.charAt(0).toUpperCase() + this.slice(1)
16		};
17
18		var weatherWidgets = $(".clima-widget");
19		for(var i =0; i < weatherWidgets.length; i++) {
20			var weatherWidget = weatherWidgets[i];
21			if (weatherWidget) {
22				var city = weatherWidget.getAttribute("data-city");
23				var country = weatherWidget.getAttribute("data-country");
24				var language = weatherWidget.getAttribute("data-language") || "spanish";
25				var location_for_rest = city.replace(" ", "_") + "," + country;
26				loadXMLDoc(weatherWidget, city, country, language, location_for_rest);
27			}
28		}
29		function loadXMLDoc(weatherWidget, city, country, language, location_for_rest) {
30			var xhr = new XMLHttpRequest();
31			xhr.onload = function () {
32				// Process our return data
33				if (xhr.status >= 200 && xhr.status < 300) {
34					// Runs when the request is successful
35					handleResponse(JSON.parse(xhr.responseText), weatherWidget, city, country, language);
36				} else {
37					// Runs when it's not
38					console.log(xhr.responseText);
39				}
40			};
41			xhr.open('GET', 'https://www.weatherwp.com/api/common/publicWeatherForLocation2.php?city=' + encodeURIComponent(city) + '&country=' + encodeURIComponent(country) + '&place=' + location_for_rest + '&domain=' + document.location + '&language=' + language + "&widget=Spanish2");
42			xhr.send();
43		}
44
45
46		function handleResponse(response, weatherWidget, city, country, language) {
47			var header = weatherWidget.getAttribute("data-header");
48			var widgetInputWidth = weatherWidget.getAttribute("data-width");
49			var days = weatherWidget.getAttribute("data-days");
50			var isCurrent = weatherWidget.getAttribute("data-current");
51			var isWind = weatherWidget.getAttribute("data-wind");
52			var isSunrise = weatherWidget.getAttribute("data-sunrise");
53			var backgroundColor = weatherWidget.getAttribute("data-background");
54			if (!backgroundColor || backgroundColor === '' || backgroundColor === '#16a2d0') {
55				backgroundColor = 'linear-gradient(to right top, #3ad7f6, #16a2d0)';
56			}
57			var textColor = weatherWidget.getAttribute("data-text-color");
58			if (!textColor || textColor === '') {
59				textColor = 'white';
60			}
61
62			//console.log(response);
63			var deepLink = response.deepLink;
64			var temp = response.temp;
65
66			var sunrise =  getWeatherInfoLine("Atardecer",response.sunrise,"sunrise",'');
67			if (language === "english") {
68				sunrise = getWeatherInfoLine("Sunrise",response.sunrise,"sunrise",'');
69			}
70
71			var sunset = getWeatherInfoLine("Puesta de sol",response.sunset,"sunset",'');
72			if (language === "english") {
73				sunset = getWeatherInfoLine("Sunset",response.sunset,"sunset",'');
74			}
75			var imageURL = response.icon;
76			var humidity = getWeatherInfoLine("Humedad",response.humidity,"humidity",'%');
77			if (language === "english") {
78				humidity = getWeatherInfoLine("Humidity",response.humidity,"humidity",'%');
79			}
80			var windspeedKmph = getWeatherInfoLine("Viento",response.windspeedKmph,"wind",'Km/h');
81			if (language === "english") {
82				windspeedKmph = getWeatherInfoLine("Wind Speed",response.windspeedKmph,"wind",'Km/h');
83			}
84
85			var chanceofrain = response.chanceofrain + "%";
86			var daysForecast = response.days;
87			var description = response.description;
88
89
90			// set tight if user asked for not 100%
91			if (widgetInputWidth === 'tight') {
92				$(weatherWidget).addClass('tight');
93			} else {
94				$(weatherWidget).addClass('maxwidth');
95			}
96
97			// get widget width
98			var widgetWidth = $(weatherWidget).width();
99			var widthClass = "regular";
100			if (widgetWidth < 200) {
101				widthClass = "super-small";
102			} else if (widgetWidth < 300) {
103				widthClass = "small";
104			} else if (widgetWidth < 380) {
105				widthClass = "medium";
106			}
107
108
109			// wrap deep link
110			var mainDeepLinkElm = document.createElement("a");
111			mainDeepLinkElm.setAttribute("href", deepLink);
112			mainDeepLinkElm.setAttribute("class", "main-link");
113			mainDeepLinkElm.setAttribute("style", "color:" + textColor);
114			mainDeepLinkElm.setAttribute("target", "_blank");
115			var title = "El clima en "+city;
116			if(language === 'english'){
117				title = "The weather in "+city;
118			}
119
120			mainDeepLinkElm.setAttribute("title", title);
121				mainDeepLinkElm.innerHTML = (response.anchorText);
122
123
124			//mainWrapElm
125			var mainWrapElm = document.createElement("div");
126			mainWrapElm.setAttribute("class", 'main_wrap ' + widthClass);
127			mainWrapElm.setAttribute("style", "background: " + backgroundColor + " ;color:" + textColor);
128
129
130			if (true) {
131				// center wrap
132				var centerWrapElm = document.createElement("div");
133				centerWrapElm.setAttribute("class", "weather_center_wrap");
134
135				// temp wrap
136				var tempWrap = document.createElement("div");
137				tempWrap.setAttribute("class", "weather_temp_wrap");
138
139				// temp
140				var tempElm = document.createElement("span");
141				tempElm.innerHTML = temp + '&#176;';
142				tempElm.setAttribute("class", "weather_temp");
143				tempWrap.appendChild(tempElm);
144
145				// image
146				var imageWrapElm = document.createElement("div");
147				var imageElm = document.createElement("img");
148				imageElm.setAttribute("src", imageURL);
149
150				imageElm.setAttribute("class", "weather_image");
151				imageWrapElm.setAttribute("class", "weather_image_wrap");
152				imageWrapElm.appendChild(imageElm);
153
154				// center center
155				var centerCenterElm = document.createElement("div");
156				centerCenterElm.setAttribute("class", "center-center");
157
158				// description
159				var descriptionElm = document.createElement("div");
160				descriptionElm.innerHTML = description;
161				descriptionElm.setAttribute("class", "weather_description");
162
163
164				// city name
165				var cityNameElm = document.createElement("div");
166				cityNameElm.innerHTML = city.capitalize();
167				cityNameElm.setAttribute("class", "city-name");
168
169				centerCenterElm.appendChild(cityNameElm);
170				centerCenterElm.appendChild(descriptionElm);
171
172				centerWrapElm.appendChild(imageWrapElm);
173				centerWrapElm.appendChild(centerCenterElm);
174				centerWrapElm.appendChild(tempWrap);
175				mainWrapElm.appendChild(centerWrapElm);
176			}
177
178			if (isSunrise === 'on' || isWind === 'on'){
179				var weatherDataElm = document.createElement("div");
180				weatherDataElm.setAttribute("class", "weather-info-wrap");
181			}
182
183			if (isSunrise === 'on') {
184				weatherDataElm.appendChild(sunrise);
185				weatherDataElm.appendChild(sunset);
186			}
187
188
189			if (isWind === 'on') {
190				weatherDataElm.appendChild(humidity);
191
192				weatherDataElm.appendChild(windspeedKmph);
193			}
194
195
196			if (isSunrise === 'on' || isWind === 'on') {
197				mainWrapElm.appendChild(weatherDataElm);
198			}
199
200			// days
201			if (Number(days) > 0) {
202				var daysWrap = document.createElement("div");
203				daysWrap.setAttribute("class", "weather_days_wrap"); //"");
204
205				for (var i = 0; i < Number(days); i++) {
206					var dayElm = document.createElement("div");
207					var dayElmWidth = "33.3%";
208					if (Number(days) === 2 || Number(days) === 4) {
209						dayElmWidth = "50%";
210					}
211					dayElm.setAttribute("class", "weather_day_wrap"); //"width: " + dayElmWidth + "; text-align: center;margin: 10px 0px;");
212					// day name
213					var dayNameElm = document.createElement("div");
214					dayNameElm.innerHTML = daysForecast[i].dayName;
215					dayNameElm.setAttribute("class", "weather_day_name"); //"");
216					dayElm.appendChild(dayNameElm);
217
218					// day image
219					var dayImageWrapElm = document.createElement("div");
220					var dayImageElm = document.createElement("img");
221					dayImageElm.setAttribute("class", "weather_day_image"); //"");
222					dayImageElm.setAttribute("src", daysForecast[i].icon);
223					dayImageWrapElm.setAttribute("class", "weather_day_image_wrap"); //"");
224					dayImageWrapElm.appendChild(dayImageElm);
225					dayElm.appendChild(dayImageWrapElm);
226
227					// day temp
228					var dayTempElm = document.createElement("div");
229					dayTempElm.innerHTML = daysForecast[i].max + '&#176;';
230					dayTempElm.setAttribute("class", "weather_day_temp"); //"");
231					dayElm.appendChild(dayTempElm);
232					daysWrap.appendChild(dayElm);
233				}
234				mainWrapElm.appendChild(daysWrap);
235			}
236
237
238			// mainDeepLinkElm.prepend(mainWrapElm);
239
240			mainWrapElm.append(mainDeepLinkElm);
241			weatherWidget.prepend(mainWrapElm);
242		}
243
244	});
245
246})(jQuery);
247
248function getWeatherInfoLine(label,value,classToUse,sign){
249
250	var data = '<div class="weather-info-label">'+label+'</div>' +
251		'<div class="weather-info-value">' + value + sign + '</div>';
252
253	var elm = document.createElement("div");
254	elm.setAttribute("class", "weather-info-point "+classToUse);
255	elm.innerHTML = data;
256
257	return elm;
258}

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.