PageSourceSearch

https://festival.warszawa.pl/wp-content/plugins/wettervorhersage/p…/js/wettervorhersage-public.js?ver=1.0.0

js festival.warszawa.pl collected 2026-10-02 21:54:45 UTC 8,694 bytes, 256 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 = $(".wettervorhersage-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") || "german";
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/publicWeatherForLocation.php?city=' + encodeURIComponent(city) + '&country=' + encodeURIComponent(country) + '&place=' + location_for_rest + '&domain=' + document.location + '&language=' + language+ '&widget=German2');
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("Sonnenaufgang",response.sunrise,"sunrise",'');
67			if (language === "english") {
68				sunrise = getWeatherInfoLine("Sunrise",response.sunrise,"sunrise",'');
69			}
70
71			var sunset = getWeatherInfoLine("Sonnenuntergang",response.sunset,"sunset",'');
72			if (language === "english") {
73				sunset = getWeatherInfoLine("Sunset",response.sunset,"sunset",'');
74			}
75			var imageURL = response.icon;
76			var humidity = getWeatherInfoLine("Feuchtigkeit",response.humidity,"humidity",'%');
77			if (language === "english") {
78				humidity = getWeatherInfoLine("Humidity",response.humidity,"humidity",'%');
79			}
80			var windspeedKmph = getWeatherInfoLine("Windgeschwindigkeit",response.windspeedKmph,"wind",'Km/h');
81			if (language === "english") {
82				windspeedKmph = getWeatherInfoLine("Wind Speed",response.windspeedKmph,"wind",'Km/h');
83			}
84
85
86
87				var chanceofrain = response.chanceofrain + "%";
88			var daysForecast = response.days;
89			var description = response.description;
90
91
92			// set tight if user asked for not 100%
93			if (widgetInputWidth === 'tight') {
94				$(weatherWidget).addClass('tight');
95			} else {
96				$(weatherWidget).addClass('maxwidth');
97			}
98
99			// get widget width
100			var widgetWidth = $(weatherWidget).width();
101			var widthClass = "regular";
102			if (widgetWidth < 200) {
103				widthClass = "super-small";
104			} else if (widgetWidth < 300) {
105				widthClass = "small";
106			} else if (widgetWidth < 380) {
107				widthClass = "medium";
108			}
109
110
111			// wrap deep link
112			var mainDeepLinkElm = document.createElement("a");
113			mainDeepLinkElm.setAttribute("href", deepLink);
114			mainDeepLinkElm.setAttribute("target", "_blank");
115			var title = "Das wetter in "+city;
116			if(language === 'english'){
117				title = "The weather in "+city;
118			}
119
120			mainDeepLinkElm.setAttribute("title", title);
121
122
123			//mainWrapElm
124			var mainWrapElm = document.createElement("div");
125			mainWrapElm.setAttribute("class", 'main_wrap ' + widthClass);
126			mainWrapElm.setAttribute("style", "background: " + backgroundColor + " ;color:" + textColor);
127
128
129			if (true) {
130				// center wrap
131				var centerWrapElm = document.createElement("div");
132				centerWrapElm.setAttribute("class", "weather_center_wrap");
133
134				// temp wrap
135				var tempWrap = document.createElement("div");
136				tempWrap.setAttribute("class", "weather_temp_wrap");
137
138				// temp
139				var tempElm = document.createElement("span");
140				tempElm.innerHTML = temp + '&#176;';
141				tempElm.setAttribute("class", "weather_temp");
142				tempWrap.appendChild(tempElm);
143
144				// image
145				var imageWrapElm = document.createElement("div");
146				var imageElm = document.createElement("img");
147				imageElm.setAttribute("src", imageURL);
148
149				imageElm.setAttribute("class", "weather_image");
150				imageWrapElm.setAttribute("class", "weather_image_wrap");
151				imageWrapElm.appendChild(imageElm);
152
153				// center center
154				var centerCenterElm = document.createElement("div");
155				centerCenterElm.setAttribute("class", "center-center");
156
157				// description
158				var descriptionElm = document.createElement("div");
159				descriptionElm.innerHTML = description;
160				descriptionElm.setAttribute("class", "weather_description");
161
162
163				// city name
164				var cityNameElm = document.createElement("div");
165				cityNameElm.innerHTML = city.capitalize();
166				cityNameElm.setAttribute("class", "city-name");
167
168				centerCenterElm.appendChild(cityNameElm);
169				centerCenterElm.appendChild(descriptionElm);
170
171				centerWrapElm.appendChild(imageWrapElm);
172				centerWrapElm.appendChild(centerCenterElm);
173				centerWrapElm.appendChild(tempWrap);
174				mainWrapElm.appendChild(centerWrapElm);
175			}
176
177			if (isSunrise === 'on' || isWind === 'on'){
178				var weatherDataElm = document.createElement("div");
179				weatherDataElm.setAttribute("class", "weather-info-wrap");
180			}
181
182			if (isSunrise === 'on') {
183				weatherDataElm.appendChild(sunrise);
184				weatherDataElm.appendChild(sunset);
185			}
186
187
188			if (isWind === 'on') {
189				weatherDataElm.appendChild(humidity);
190
191				weatherDataElm.appendChild(windspeedKmph);
192			}
193
194
195			if (isSunrise === 'on' || isWind === 'on') {
196				mainWrapElm.appendChild(weatherDataElm);
197			}
198
199			// days
200			if (Number(days) > 0) {
201				var daysWrap = document.createElement("div");
202				daysWrap.setAttribute("class", "weather_days_wrap"); //"");
203
204				for (var i = 0; i < Number(days); i++) {
205					var dayElm = document.createElement("div");
206					var dayElmWidth = "33.3%";
207					if (Number(days) === 2 || Number(days) === 4) {
208						dayElmWidth = "50%";
209					}
210					dayElm.setAttribute("class", "weather_day_wrap"); //"width: " + dayElmWidth + "; text-align: center;margin: 10px 0px;");
211					// day name
212					var dayNameElm = document.createElement("div");
213					dayNameElm.innerHTML = daysForecast[i].dayName;
214					dayNameElm.setAttribute("class", "weather_day_name"); //"");
215					dayElm.appendChild(dayNameElm);
216
217					// day image
218					var dayImageWrapElm = document.createElement("div");
219					var dayImageElm = document.createElement("img");
220					dayImageElm.setAttribute("class", "weather_day_image"); //"");
221					dayImageElm.setAttribute("src", daysForecast[i].icon);
222					dayImageWrapElm.setAttribute("class", "weather_day_image_wrap"); //"");
223					dayImageWrapElm.appendChild(dayImageElm);
224					dayElm.appendChild(dayImageWrapElm);
225
226					// day temp
227					var dayTempElm = document.createElement("div");
228					dayTempElm.innerHTML = daysForecast[i].max + '&#176;';
229					dayTempElm.setAttribute("class", "weather_day_temp"); //"");
230					dayElm.appendChild(dayTempElm);
231					daysWrap.appendChild(dayElm);
232				}
233				mainWrapElm.appendChild(daysWrap);
234			}
235
236
237			mainDeepLinkElm.prepend(mainWrapElm);
238
239			weatherWidget.prepend(mainDeepLinkElm);
240		}
241
242	});
243
244})(jQuery);
245
246function getWeatherInfoLine(label,value,classToUse,sign){
247
248	var data = '<div class="weather-info-label">'+label+'</div>' +
249		'<div class="weather-info-value">' + value + sign + '</div>';
250
251	var elm = document.createElement("div");
252	elm.setAttribute("class", "weather-info-point "+classToUse);
253	elm.innerHTML = data;
254
255	return elm;
256}

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.