PageSourceSearch

https://www.xn--forbrukslnoversikt-dub.com/wp-content/plugins/vejr…/public/js/vejret-public.js?ver=1.0.0

js xn--forbrukslnoversikt-dub.com collected 2026-10-09 22:41:50 UTC 8,309 bytes, 241 lines download raw bytes

1(function ($) {
2	'use strict';
3	$(function () {
4		String.prototype.capitalize = function () {
5			return this.charAt(0).toUpperCase() + this.slice(1)
6		};
7		var weatherWidget = document.getElementById("weather-widget-vejret");
8		if (weatherWidget) {
9			var city = weatherWidget.getAttribute("data-city");
10			var country = weatherWidget.getAttribute("data-country");
11			var days = weatherWidget.getAttribute("data-days");
12			var language = weatherWidget.getAttribute("data-language") || "danish";
13			var isCurrent = weatherWidget.getAttribute("data-current");
14			var isWind = weatherWidget.getAttribute("data-wind");
15			var isSunrise = weatherWidget.getAttribute("data-sunrise");
16			var backgroundColor = weatherWidget.getAttribute("data-background");
17			if (!backgroundColor || backgroundColor == '' || backgroundColor == '#becffb') {
18				backgroundColor = 'linear-gradient(to left, #d3dfff, #fbfcff)';
19			}
20			var textColor = weatherWidget.getAttribute("data-text-color");
21			if (!textColor || textColor == '') {
22				textColor = 'black';
23			}
24			var widgetInputWidth = weatherWidget.getAttribute("data-width");
25			var location_for_rest = city.replace(" ", "_") + "," + country;
26			location_for_rest = location_for_rest;
27			loadXMLDoc(location_for_rest);
28		}
29
30		function loadXMLDoc() {
31			var xhr = new XMLHttpRequest();
32			xhr.onload = function () {
33				// Process our return data
34				if (xhr.status >= 200 && xhr.status < 300) {
35					// Runs when the request is successful
36					handleResponse(JSON.parse(xhr.responseText));
37				} else {
38					// Runs when it's not
39					console.log(xhr.responseText);
40				}
41			};
42			xhr.open('GET', 'https://www.vejreti.com/weather/rests/publicWeatherForLocation.php?city=' + encodeURIComponent(city) + '&country=' + encodeURIComponent(country) + '&place=' + location_for_rest + '&domain=' + document.location + '&language=' + language);
43			xhr.send();
44		}
45
46
47		function handleResponse(response) {
48			//console.log(response);
49			var deepLink = response.deepLink;
50			var title = "Vejret i " + city.capitalize();
51			if (language == "english") {
52				title = "Weather in " + city.capitalize();
53			}
54			var temp = response.temp + '&#176;';
55			var tempType = "C";
56			var sunrise = "Sunrise: " + response.sunrise;
57			if (language == "english") {
58				sunrise = "Sunrise: " + response.sunrise;
59			}
60			var sunset = "Sunset: " + response.sunset;
61			if (language == "english") {
62				sunset = "Sunset: " + response.sunset;
63			}
64			var imageURL = response.icon;
65			var humidity = "Fugtighed: " + response.humidity + "%";
66			if (language == "english") {
67				humidity = "Humidity: " + response.humidity + "%";
68			}
69			var windspeedKmph = "Vindhastighed: " + response.windspeedKmph + "Kmph";
70			if (language == "english") {
71				windspeedKmph = "Wind Speed: " + response.windspeedKmph + "Kmph";
72			}
73			var chanceofrain = "Chance for regn: " + response.chanceofrain + "%";
74			if (language == "english") {
75				chanceofrain = "Chance for rain: " + response.chanceofrain + "%";
76			}
77			var daysForecast = response.days;
78			var description = response.description;
79
80
81			// set tight if user asked for not 100%
82			if (widgetInputWidth == 'tight') {
83				$(weatherWidget).addClass('tight');
84			} else {
85				$(weatherWidget).addClass('maxwidth');
86			}
87
88			// get widget width
89			var widgetWidth = $(weatherWidget).width();
90			var widthClass = "regular";
91			if (widgetWidth < 200) {
92				widthClass = "super-small";
93			} else if (widgetWidth < 300) {
94				widthClass = "small";
95			}
96
97
98			// wrap deep link
99			var mainDeepLinkElm = document.createElement("a");
100			mainDeepLinkElm.setAttribute("href", deepLink);
101
102			//mainWrapElm
103			var mainWrapElm = document.createElement("div");
104			mainWrapElm.setAttribute("class", 'main_wrap ' + widthClass);
105			mainWrapElm.setAttribute("style", "background: " + backgroundColor + " ;color:" + textColor);
106
107			//title
108			var titleElm = document.createElement("div");
109			titleElm.innerHTML = title;
110			titleElm.setAttribute("class", "weather_title");
111			mainWrapElm.appendChild(titleElm);
112
113			if (isCurrent == "on") {
114				// center wrap
115				var centerWrapElm = document.createElement("div");
116				centerWrapElm.setAttribute("class", "weather_center_wrap");
117
118				// temp wrap
119				var tempWrap = document.createElement("div");
120				tempWrap.setAttribute("class", "weather_temp_wrap");
121
122				// temp
123				var tempElm = document.createElement("span");
124				tempElm.innerHTML = temp;
125				tempElm.setAttribute("class", "weather_temp");
126				tempWrap.appendChild(tempElm);
127
128				// temp type
129				var tempTypeElm = document.createElement("span");
130				tempTypeElm.innerHTML = tempType;
131				tempTypeElm.setAttribute("class", "weather_temp_type");
132				tempWrap.appendChild(tempTypeElm);
133
134				// image
135				var imageWrapElm = document.createElement("div");
136				var imageElm = document.createElement("img");
137				imageElm.setAttribute("src", imageURL);
138
139				imageElm.setAttribute("class", "weather_image");
140				imageWrapElm.setAttribute("class", "weather_image_wrap");
141				imageWrapElm.appendChild(imageElm);
142
143				centerWrapElm.appendChild(imageWrapElm);
144				centerWrapElm.appendChild(tempWrap);
145				mainWrapElm.appendChild(centerWrapElm);
146
147
148				// description
149				var descriptionElm = document.createElement("div");
150				descriptionElm.innerHTML = description;
151				descriptionElm.setAttribute("class", "weather_description");
152				mainWrapElm.appendChild(descriptionElm);
153			}
154
155			if (isSunrise == 'on') {
156				// sunrise
157				var sunriseElm = document.createElement("div");
158				sunriseElm.innerHTML = sunrise;
159				sunriseElm.setAttribute("class", "weather_sunrise"); //");
160				mainWrapElm.appendChild(sunriseElm);
161
162				// sunset
163				var sunsetElm = document.createElement("div");
164				sunsetElm.innerHTML = sunset;
165				sunsetElm.setAttribute("class", "weather_sunset"); //");
166				mainWrapElm.appendChild(sunsetElm);
167			}
168
169
170			if (isWind == 'on') {
171				var weatherDataElm = document.createElement("div");
172				weatherDataElm.setAttribute("class", "weather_data_wrap"); //"");
173
174				// humidity
175				var humidityElm = document.createElement("div");
176				humidityElm.innerHTML = humidity;
177				humidityElm.setAttribute("class", "weather_humidity"); //");
178				weatherDataElm.appendChild(humidityElm);
179				// wind
180				var windElm = document.createElement("div");
181				windElm.innerHTML = windspeedKmph;
182				windElm.setAttribute("class", "weather_wind"); //");
183				weatherDataElm.appendChild(windElm);
184				// rain
185				var chanceofrainElm = document.createElement("div");
186				chanceofrainElm.innerHTML = chanceofrain;
187				chanceofrainElm.setAttribute("class", "weather_rain"); //");
188				weatherDataElm.appendChild(chanceofrainElm);
189
190				// add to dom
191				mainWrapElm.appendChild(weatherDataElm);
192			}
193
194
195			// days
196			if (Number(days) > 0) {
197				var daysWrap = document.createElement("div");
198				daysWrap.setAttribute("class", "weather_days_wrap"); //"");
199
200				for (var i = 0; i < Number(days); i++) {
201					var dayElm = document.createElement("div");
202					var dayElmWidth = "33.3%";
203					if (Number(days) == 2 || Number(days) == 4) {
204						dayElmWidth = "50%";
205					}
206					dayElm.setAttribute("class", "weather_day_wrap"); //"width: " + dayElmWidth + "; text-align: center;margin: 10px 0px;");
207					// day name
208					var dayNameElm = document.createElement("div");
209					dayNameElm.innerHTML = daysForecast[i].dayName;
210					dayNameElm.setAttribute("class", "weather_day_name"); //"");
211					dayElm.appendChild(dayNameElm);
212
213					// day image
214					var dayImageWrapElm = document.createElement("div");
215					var dayImageElm = document.createElement("img");
216					dayImageElm.setAttribute("class", "weather_day_image"); //"");
217					dayImageElm.setAttribute("src", daysForecast[i].icon);
218					dayImageWrapElm.setAttribute("class", "weather_day_image_wrap"); //"");
219					dayImageWrapElm.appendChild(dayImageElm);
220					dayElm.appendChild(dayImageWrapElm);
221
222					// day temp
223					var dayTempElm = document.createElement("div");
224					dayTempElm.innerHTML = daysForecast[i].min + "/" + daysForecast[i].max + '&#176;' + "C";
225					dayTempElm.setAttribute("class", "weather_day_temp"); //"");
226					dayElm.appendChild(dayTempElm);
227
228
229					daysWrap.appendChild(dayElm);
230				}
231				mainWrapElm.appendChild(daysWrap);
232			}
233
234			mainDeepLinkElm.prepend(mainWrapElm);
235
236			weatherWidget.prepend(mainDeepLinkElm);
237		}
238
239	});
240
241})(jQuery);

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.