PageSourceSearch

https://www.pirsch.de/modules/contrib/dlv_wetter/js/weatherWidget.js?v=1.x

js pirsch.de collected 2026-10-02 14:30:27 UTC 3,457 bytes, 84 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2  var main = function () {
3    // renderNewWeatherWidget
4    var defaultLoca = drupalSettings.dlv_wetter.wetter_url;
5    try {
6      var savedItem = localStorage.getItem('savedCity');
7      if (savedItem) {
8        defaultLoca = JSON.parse(savedItem).URL;
9      }
10      let resultData;
11      fetch('https://apicdn.dlv.de/wetterapi/v1/ort?url=' + encodeURIComponent(defaultLoca))
12        .then(res => res.json())
13        .then(resData => {
14          resultData = resData;
15          let widget = document.createElement('a');
16          widget.href = `/wetter${resData.location.URL}`;
17          let img = document.createElement('img');
18          let span = document.createElement('span')
19          span.innerText = resData.location.Locality + ' ' + resData.data_now.air_temperature[0].value;
20          img.src = `/modules/contrib/dlv_wetter/src/assets/weatherTable/${resData.data_now.weather_code[0].value}.svg`;
21          img.alt = resData.data_now.weather_code[0].value;
22          img.style.width = '32px';
23          img.style.height = '32px';
24          img.style.marginRight = '10px';
25
26          widget.appendChild(img);
27          widget.appendChild(span);
28
29          if (document.getElementById('headerWeatherContainer')) {
30            document.getElementById('headerWeatherContainer').innerHTML = '';
31            document.getElementById('headerWeatherContainer').appendChild(widget);
32          }
33
34          if (document.getElementById('mobile-weather-holder')) {
35            document.getElementById('mobile-weather-holder').innerHTML = '';
36
37            img.style.width = '28px';
38            img.style.height = '28px';
39
40            document.getElementById('mobile-weather-holder').appendChild(widget.cloneNode(true));
41          }
42
43          if (document.getElementById('header-cta')) {
44            document.getElementById('header-cta').querySelectorAll('.weatherAnchor').forEach(el => {
45              el.href = `/wetter${resData.location.URL}`;
46            });
47          }
48
49
50          //WidgetBlock Pirsch
51          if (document.getElementById('weatherWidgetBlock')) {
52            document.getElementById('location_name').innerText = resData.location.Locality;
53            const weather_page_url = document.getElementsByClassName('weather_page_url');
54            const weather_page_url_moon = document.getElementsByClassName('weather_page_url_moon');
55
56            for (const url of weather_page_url) {
57              url.href = `/wetter${resData.location.URL}`;
58            }
59
60            for (const url of weather_page_url_moon) {
61              url.href = `/wetter${resData.location.URL}#moonlightindex`;
62            }
63
64            const moonPhaseToText = phase => {
65              if (phase <= -0.94) return 'Vollmond';
66              if (phase < -0.05) return 'abnehmend';
67              if (phase <= 0.05) return 'Neumond';
68              if (phase < 0.95) return 'zunehmend';
69              return 'Vollmond';
70            }
71
72            document.getElementById('air_temperature').innerText = resData.data_now.air_temperature[0].value;
73            document.getElementById('moon_vis_area').innerText = resData.data_forecast.moon_visible_area[0].value;
74            document.getElementById('moon_phase').innerText = moonPhaseToText(resData.data_forecast.moon_phase[0].value_org);
75          }
76
77        });
78    } catch (e) { }
79  }
80
81  // run weather code
82  main()
83  window.updateWeatherWidget = main;
84});

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.