PageSourceSearch

https://bad-frankenhausen.de/wp-content/themes/citygov-child/assets/js/wettervorhersage.js?ver=1.0

js bad-frankenhausen.de collected 2026-10-02 11:07:22 UTC 10,862 bytes, 325 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		
15		if (window.m1_layer === undefined) window.m1_layer = [];
16		
17		for (let el of document.getElementsByClassName("wettervorhersage-widget")) {
18			
19			el.classList.add('m1_layer');
20			el.classList.add('placeholder');
21			el.classList.add('m1_weather');
22			el.setAttribute('data-layer_id', '14001');
23			
24			el.innerHTML = '<div class="placeholder_text">' +
25				'<strong>Datenschutz ist uns wichtig!</strong><br /><br />' +
26				'Daher wird der externe Dienst von <a href="https://www.wetter2.com">www.wetter2.com</a> erst nach Ihrer Zustimmung geladen.<br />' +
27				'Diesen Dienst nutzen wir um an dieser Stelle das Wetter anzuzeigen.' +
28				'<br /><br />' +
29				'<a href="#" class="layer_link">Ich bin einmalig damit einverstanden.</a>' +
30				'</div>';
31			
32			for (let a of el.getElementsByClassName('layer_link')) {
33			
34				a.addEventListener('click', (event) => {
35					
36					event.preventDefault();
37		
38					for (let l of window.m1_layer) {
39						
40						if (l.layer_id === 14001) {
41							
42							if (l.content) el.innerHTML = atob(l.content);
43							else if (l.function) l.function();
44							
45							el.classList.remove('placeholder');
46							
47						}
48						
49					} 
50					
51				});
52								
53			} 
54			
55		}
56		
57		window.m1_layer.push({
58			layer_id: 14001,
59			function: () => {
60		
61				String.prototype.capitalize = function () {
62			return this.charAt(0).toUpperCase() + this.slice(1)
63		};
64
65				var weatherWidgets = $(".wettervorhersage-widget");
66				for(var i =0; i < weatherWidgets.length; i++) {
67					var weatherWidget = weatherWidgets[i];
68					if (weatherWidget) {
69						var city = weatherWidget.getAttribute("data-city");
70						var country = weatherWidget.getAttribute("data-country");
71						var language = weatherWidget.getAttribute("data-language") || "german";
72						var location_for_rest = city.replace(" ", "_") + "," + country;
73						loadXMLDoc(weatherWidget, city, country, language, location_for_rest);
74					}
75				}
76				function loadXMLDoc(weatherWidget, city, country, language, location_for_rest) {
77					var xhr = new XMLHttpRequest();
78					xhr.onload = function () {
79						// Process our return data
80						if (xhr.status >= 200 && xhr.status < 300) {
81							// Runs when the request is successful
82							handleResponse(JSON.parse(xhr.responseText), weatherWidget, city, country, language);
83						} else {
84							// Runs when it's not
85							console.log(xhr.responseText);
86						}
87					};
88					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');
89					xhr.send();
90				}
91		
92		
93				function handleResponse(response, weatherWidget, city, country, language) {
94					var header = weatherWidget.getAttribute("data-header");
95					var widgetInputWidth = weatherWidget.getAttribute("data-width");
96					var days = weatherWidget.getAttribute("data-days");
97					var isCurrent = weatherWidget.getAttribute("data-current");
98					var isWind = weatherWidget.getAttribute("data-wind");
99					var isSunrise = weatherWidget.getAttribute("data-sunrise");
100					var backgroundColor = weatherWidget.getAttribute("data-background");
101					if (!backgroundColor || backgroundColor === '' || backgroundColor === '#16a2d0') {
102						backgroundColor = 'linear-gradient(to right top, #3ad7f6, #16a2d0)';
103					}
104					var textColor = weatherWidget.getAttribute("data-text-color");
105					if (!textColor || textColor === '') {
106						textColor = 'white';
107					}
108		
109					//console.log(response);
110					var deepLink = response.deepLink;
111					var temp = response.temp;
112		
113					var sunrise =  getWeatherInfoLine("Sonnenaufgang",response.sunrise,"sunrise",'');
114					if (language === "english") {
115						sunrise = getWeatherInfoLine("Sunrise",response.sunrise,"sunrise",'');
116					}
117		
118					var sunset = getWeatherInfoLine("Sonnenuntergang",response.sunset,"sunset",'');
119					if (language === "english") {
120						sunset = getWeatherInfoLine("Sunset",response.sunset,"sunset",'');
121					}
122					var imageURL = response.icon;
123					var humidity = getWeatherInfoLine("Feuchtigkeit",response.humidity,"humidity",'%');
124					if (language === "english") {
125						humidity = getWeatherInfoLine("Humidity",response.humidity,"humidity",'%');
126					}
127					var windspeedKmph = getWeatherInfoLine("Windgeschwindigkeit",response.windspeedKmph,"wind",'Km/h');
128					if (language === "english") {
129						windspeedKmph = getWeatherInfoLine("Wind Speed",response.windspeedKmph,"wind",'Km/h');
130					}
131		
132		
133		
134						var chanceofrain = response.chanceofrain + "%";
135					var daysForecast = response.days;
136					var description = response.description;
137		
138		
139					// set tight if user asked for not 100%
140					if (widgetInputWidth === 'tight') {
141						$(weatherWidget).addClass('tight');
142					} else {
143						$(weatherWidget).addClass('maxwidth');
144					}
145		
146					// get widget width
147					var widgetWidth = $(weatherWidget).width();
148					var widthClass = "regular";
149					if (widgetWidth < 200) {
150						widthClass = "super-small";
151					} else if (widgetWidth < 300) {
152						widthClass = "small";
153					} else if (widgetWidth < 380) {
154						widthClass = "medium";
155					}
156		
157		
158					// wrap deep link
159					var mainDeepLinkElm = document.createElement("a");
160					mainDeepLinkElm.setAttribute("href", deepLink);
161					mainDeepLinkElm.setAttribute("target", "_blank");
162					var title = "Das wetter in "+city;
163					if(language === 'english'){
164						title = "The weather in "+city;
165					}
166		
167					mainDeepLinkElm.setAttribute("title", title);
168		
169		
170					//mainWrapElm
171					var mainWrapElm = document.createElement("div");
172					mainWrapElm.setAttribute("class", 'main_wrap ' + widthClass);
173					mainWrapElm.setAttribute("style", "background: " + backgroundColor + " ;color:" + textColor);
174		
175		
176					if (true) {
177						// center wrap
178						var centerWrapElm = document.createElement("div");
179						centerWrapElm.setAttribute("class", "weather_center_wrap");
180		
181						// temp wrap
182						var tempWrap = document.createElement("div");
183						tempWrap.setAttribute("class", "weather_temp_wrap");
184		
185						// temp
186						var tempElm = document.createElement("span");
187						tempElm.innerHTML = temp + '&#176;';
188						tempElm.setAttribute("class", "weather_temp");
189						tempWrap.appendChild(tempElm);
190		
191						// image
192						var imageWrapElm = document.createElement("div");
193						var imageElm = document.createElement("img");
194						imageElm.setAttribute("src", imageURL);
195		
196						imageElm.setAttribute("class", "weather_image");
197						imageWrapElm.setAttribute("class", "weather_image_wrap");
198						imageWrapElm.appendChild(imageElm);
199		
200						// center center
201						var centerCenterElm = document.createElement("div");
202						centerCenterElm.setAttribute("class", "center-center");
203		
204						// description
205						var descriptionElm = document.createElement("div");
206						descriptionElm.innerHTML = description;
207						descriptionElm.setAttribute("class", "weather_description");
208		
209		
210						// city name
211						var cityNameElm = document.createElement("div");
212						cityNameElm.innerHTML = city.capitalize();
213						cityNameElm.setAttribute("class", "city-name");
214		
215						centerCenterElm.appendChild(cityNameElm);
216						centerCenterElm.appendChild(descriptionElm);
217		
218						centerWrapElm.appendChild(imageWrapElm);
219						centerWrapElm.appendChild(centerCenterElm);
220						centerWrapElm.appendChild(tempWrap);
221						mainWrapElm.appendChild(centerWrapElm);
222					}
223		
224					if (isSunrise === 'on' || isWind === 'on'){
225						var weatherDataElm = document.createElement("div");
226						weatherDataElm.setAttribute("class", "weather-info-wrap");
227					}
228		
229					if (isSunrise === 'on') {
230						weatherDataElm.appendChild(sunrise);
231						weatherDataElm.appendChild(sunset);
232					}
233		
234		
235					if (isWind === 'on') {
236						weatherDataElm.appendChild(humidity);
237		
238						weatherDataElm.appendChild(windspeedKmph);
239					}
240		
241		
242					if (isSunrise === 'on' || isWind === 'on') {
243						mainWrapElm.appendChild(weatherDataElm);
244					}
245		
246					// days
247					if (Number(days) > 0) {
248						var daysWrap = document.createElement("div");
249						daysWrap.setAttribute("class", "weather_days_wrap"); //"");
250		
251						for (var i = 0; i < Number(days); i++) {
252							var dayElm = document.createElement("div");
253							var dayElmWidth = "33.3%";
254							if (Number(days) === 2 || Number(days) === 4) {
255								dayElmWidth = "50%";
256							}
257							dayElm.setAttribute("class", "weather_day_wrap"); //"width: " + dayElmWidth + "; text-align: center;margin: 10px 0px;");
258							// day name
259							var dayNameElm = document.createElement("div");
260							dayNameElm.innerHTML = daysForecast[i].dayName;
261							dayNameElm.setAttribute("class", "weather_day_name"); //"");
262							dayElm.appendChild(dayNameElm);
263		
264							// day image
265							var dayImageWrapElm = document.createElement("div");
266							var dayImageElm = document.createElement("img");
267							dayImageElm.setAttribute("class", "weather_day_image"); //"");
268							dayImageElm.setAttribute("src", daysForecast[i].icon);
269							dayImageWrapElm.setAttribute("class", "weather_day_image_wrap"); //"");
270							dayImageWrapElm.appendChild(dayImageElm);
271							dayElm.appendChild(dayImageWrapElm);
272		
273							// day temp
274							var dayTempElm = document.createElement("div");
275							dayTempElm.innerHTML = daysForecast[i].max + '&#176;';
276							dayTempElm.setAttribute("class", "weather_day_temp"); //"");
277							dayElm.appendChild(dayTempElm);
278							daysWrap.appendChild(dayElm);
279						}
280						mainWrapElm.appendChild(daysWrap);
281					}
282		
283		
284					mainDeepLinkElm.prepend(mainWrapElm);
285		
286					weatherWidget.prepend(mainDeepLinkElm);
287				}
288				
289			}
290		});
291		
292		if (window.maps_accepted && window.maps_accepted === true) {
293					
294			for (let l of window.m1_layer) {
295				
296				if (l.layer_id === 14001) {
297					
298					let m1_layer = document.querySelector('div[data-layer_id="' + l.layer_id + '"]');
299					
300					if (l.content) m1_layer.innerHTML = atob(l.content);
301					else if (l.function) l.function();
302					
303					m1_layer.classList.remove('placeholder');
304					
305				}
306				
307			} 
308			
309		}
310		
311	});
312
313})(jQuery);
314
315function getWeatherInfoLine(label,value,classToUse,sign){
316
317	var data = '<div class="weather-info-label">'+label+'</div>' +
318		'<div class="weather-info-value">' + value + sign + '</div>';
319
320	var elm = document.createElement("div");
321	elm.setAttribute("class", "weather-info-point "+classToUse);
322	elm.innerHTML = data;
323
324	return elm;
325}

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.