PageSourceSearch

https://www.bisamberg.at/wp-content/plugins/wetter/public/js/wetter-public.js?ver=1.0.0

js bisamberg.at collected 2026-10-02 12:25:58 UTC 11,221 bytes, 255 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 = $(".wetter-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.wetter2.com/weather/rests/publicWeatherForLocation.php?city=' + encodeURIComponent(city) + '&country=' + encodeURIComponent(country) + '&place=' + location_for_rest + '&domain=' + document.location + '&language=' + language);
42                xhr.send();
43        }
44
45
46        function handleResponse(response, weatherWidget, city, country, language) {
47            var days = weatherWidget.getAttribute("data-days");
48            var widgetInputWidth = weatherWidget.getAttribute("data-width");
49            var isCurrent = weatherWidget.getAttribute("data-current");
50            var isWind = weatherWidget.getAttribute("data-wind");
51            var isSunrise = weatherWidget.getAttribute("data-sunrise");
52            var backgroundColor = weatherWidget.getAttribute("data-background");
53            if (!backgroundColor || backgroundColor == '' || backgroundColor == '#becffb') {
54                backgroundColor = 'linear-gradient(to left, #d3dfff, #fbfcff)';
55            }
56            var textColor = weatherWidget.getAttribute("data-text-color");
57            if (!textColor || textColor == '') {
58                textColor = 'black';
59            }
60
61            //console.log(response);
62            var deepLink = response.deepLink;
63            var title = "Wetter in " + city.capitalize();
64            if (language == "english") {
65                title = "Weather in " + city.capitalize();
66            }
67            var temp = response.temp + '&#176;';
68            var tempType = "C";
69            var sunrise = "Sonnenaufgang: " + response.sunrise;
70            if (language == "english") {
71                sunrise = "Sunrise: " + response.sunrise;
72            }
73            var sunset = "Sonnenuntergang: " + response.sunset;
74            if (language == "english") {
75                sunset = "Sunset: " + response.sunset;
76            }
77            var imageURL = response.icon;
78            var humidity = "Feuchtigkeit: " + response.humidity + "%";
79            if (language == "english") {
80                humidity = "Humidity: " + response.humidity + "%";
81            }
82            var windspeedKmph = "Windgeschwindigkeit: " + response.windspeedKmph + " Km/h";
83            if (language == "english") {
84                windspeedKmph = "Wind Speed: " + response.windspeedKmph + " Km/h";
85            }
86            var chanceofrain = "Chance für Regen: " + response.chanceofrain + "%";
87            if (language == "english") {
88                chanceofrain = "Chance for rain: " + response.chanceofrain + "%";
89            }
90            var daysForecast = response.days;
91            var description = response.description;
92
93
94            // set tight if user asked for not 100%
95            if (widgetInputWidth == 'tight') {
96                $(weatherWidget).addClass('tight');
97            } else {
98                $(weatherWidget).addClass('maxwidth');
99            }
100
101            // get widget width
102            var widgetWidth = $(weatherWidget).width();
103            var widthClass = "regular";
104            if (widgetWidth < 200) {
105                widthClass = "super-small";
106            } else if (widgetWidth < 300) {
107                widthClass = "small";
108            }
109
110
111            // wrap deep link
112            var mainDeepLinkElm = document.createElement("a");
113            mainDeepLinkElm.setAttribute("href", deepLink);
114            mainDeepLinkElm.setAttribute("target", "_blank");
115
116            //mainWrapElm
117            var mainWrapElm = document.createElement("div");
118            mainWrapElm.setAttribute("class", 'main_wrap ' + widthClass);
119            mainWrapElm.setAttribute("style", "background: " + backgroundColor + " ;color:" + textColor);
120
121            //title
122            var titleElm = document.createElement("div");
123            titleElm.innerHTML = title;
124            titleElm.setAttribute("class", "weather_title");
125            mainWrapElm.appendChild(titleElm);
126
127            if (isCurrent == "on") {
128                // center wrap
129                var centerWrapElm = document.createElement("div");
130                centerWrapElm.setAttribute("class", "weather_center_wrap");
131
132                // temp wrap
133                var tempWrap = document.createElement("div");
134                tempWrap.setAttribute("class", "weather_temp_wrap");
135
136                // temp
137                var tempElm = document.createElement("span");
138                tempElm.innerHTML = temp;
139                tempElm.setAttribute("class", "weather_temp");
140                tempWrap.appendChild(tempElm);
141
142                // temp type
143                var tempTypeElm = document.createElement("span");
144                tempTypeElm.innerHTML = tempType;
145                tempTypeElm.setAttribute("class", "weather_temp_type");
146                tempWrap.appendChild(tempTypeElm);
147
148                // image
149                var imageWrapElm = document.createElement("div");
150                var imageElm = document.createElement("img");
151                imageElm.setAttribute("src", imageURL);
152
153                imageElm.setAttribute("class", "weather_image");
154                imageWrapElm.setAttribute("class", "weather_image_wrap");
155                imageWrapElm.appendChild(imageElm);
156
157                centerWrapElm.appendChild(imageWrapElm);
158                centerWrapElm.appendChild(tempWrap);
159                mainWrapElm.appendChild(centerWrapElm);
160
161
162                // description
163                var descriptionElm = document.createElement("div");
164                descriptionElm.innerHTML = description;
165                descriptionElm.setAttribute("class", "weather_description");
166                mainWrapElm.appendChild(descriptionElm);
167            }
168
169            if (isSunrise == 'on') {
170                // sunrise
171                var sunriseElm = document.createElement("div");
172                sunriseElm.innerHTML = sunrise;
173                sunriseElm.setAttribute("class", "weather_sunrise"); //");
174                mainWrapElm.appendChild(sunriseElm);
175
176                // sunset
177                var sunsetElm = document.createElement("div");
178                sunsetElm.innerHTML = sunset;
179                sunsetElm.setAttribute("class", "weather_sunset"); //");
180                mainWrapElm.appendChild(sunsetElm);
181            }
182
183
184            if (isWind == 'on') {
185                var weatherDataElm = document.createElement("div");
186                weatherDataElm.setAttribute("class", "weather_data_wrap"); //"");
187
188                // humidity
189                var humidityElm = document.createElement("div");
190                humidityElm.innerHTML = humidity;
191                humidityElm.setAttribute("class", "weather_humidity"); //");
192                weatherDataElm.appendChild(humidityElm);
193                // wind
194                var windElm = document.createElement("div");
195                windElm.innerHTML = windspeedKmph;
196                windElm.setAttribute("class", "weather_wind"); //");
197                weatherDataElm.appendChild(windElm);
198                // rain
199                var chanceofrainElm = document.createElement("div");
200                chanceofrainElm.innerHTML = chanceofrain;
201                chanceofrainElm.setAttribute("class", "weather_rain"); //");
202                weatherDataElm.appendChild(chanceofrainElm);
203
204                // add to dom
205                mainWrapElm.appendChild(weatherDataElm);
206            }
207
208
209            // days
210            if (Number(days) > 0) {
211                var daysWrap = document.createElement("div");
212                daysWrap.setAttribute("class", "weather_days_wrap"); //"");
213
214                for (var i = 0; i < Number(days); i++) {
215                    var dayElm = document.createElement("div");
216                    var dayElmWidth = "33.3%";
217                    if (Number(days) == 2 || Number(days) == 4) {
218                        dayElmWidth = "50%";
219                    }
220                    dayElm.setAttribute("class", "weather_day_wrap"); //"width: " + dayElmWidth + "; text-align: center;margin: 10px 0px;");
221                    // day name
222                    var dayNameElm = document.createElement("div");
223                    dayNameElm.innerHTML = daysForecast[i].dayName;
224                    dayNameElm.setAttribute("class", "weather_day_name"); //"");
225                    dayElm.appendChild(dayNameElm);
226
227                    // day image
228                    var dayImageWrapElm = document.createElement("div");
229                    var dayImageElm = document.createElement("img");
230                    dayImageElm.setAttribute("class", "weather_day_image"); //"");
231                    dayImageElm.setAttribute("src", daysForecast[i].icon);
232                    dayImageWrapElm.setAttribute("class", "weather_day_image_wrap"); //"");
233                    dayImageWrapElm.appendChild(dayImageElm);
234                    dayElm.appendChild(dayImageWrapElm);
235
236                    // day temp
237                    var dayTempElm = document.createElement("div");
238                    dayTempElm.innerHTML = daysForecast[i].min + "/" + daysForecast[i].max + '&#176;' + "C";
239                    dayTempElm.setAttribute("class", "weather_day_temp"); //"");
240                    dayElm.appendChild(dayTempElm);
241
242
243                    daysWrap.appendChild(dayElm);
244                }
245                mainWrapElm.appendChild(daysWrap);
246            }
247
248            mainDeepLinkElm.prepend(mainWrapElm);
249
250            weatherWidget.prepend(mainDeepLinkElm);
251        }
252
253    });
254
255})(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.