PageSourceSearch

https://marlboroughmarinas.co.nz/wp-content/plugins/weather/js/getWeather.js?1791511320&ver=7.1.3

js marlboroughmarinas.co.nz collected 2026-10-09 02:02:26 UTC 8,495 bytes, 251 lines download raw bytes

1jQuery( document ).ready(function($) {
2
3var weatherLoc = $('#shortcode-weather-location').text();
4console.log('Getting weather from shortcode: ' + weatherLoc);
5$('.expand-weather').on("click", function(e) {
6  console.log(this);
7    e.preventDefault();
8
9  if ( $( "#forecast" ).is( ":hidden" ) ) {
10    $('#forecast').slideDown( "slow" );
11  } else {
12    $('#forecast').slideUp( "slow" );
13  }
14});
15
16
17$.get( "?getWeather&location=" + weatherLoc + "", function( data ) {
18  console.log(data.forecasts[0].low);
19  $('#summary .temp .data').html(data.current_observation.condition.temperature);
20  $('#summary .weather .icon-font i').html(getWeatherIcon(data.current_observation.condition.code));
21  $('#summary .location span').html(data.location.city);
22
23  $('#forecast .forecast.current .weather .icon-font i').html(getWeatherIcon(data.current_observation.condition.code));
24  $('#forecast .forecast.current .weather .description').html(data.current_observation.condition.text);
25
26  $('#forecast .forecast.current .weather .temp-current .data').html(data.current_observation.condition.temperature);
27  $('#forecast .forecast.current .weather .temp-feels .data').html(data.current_observation.wind.chill);
28
29  $('#forecast .forecast.current .tempdetail .temp-low .data').html(data.forecasts[0].low);
30  $('#forecast .forecast.current .tempdetail .temp-high .data').html(data.forecasts[0].high);
31
32  $('#forecast .forecast.current .sunrise .data').html(data.current_observation.astronomy.sunrise);
33  $('#forecast .forecast.current .sunset .data').html(data.current_observation.astronomy.sunset);
34  $('#forecast .forecast.current .humidity .data').html(data.current_observation.atmosphere.humidity + '%');
35  $('#forecast .forecast.current .pressure .data').html(data.current_observation.atmosphere.pressure + 'mb');
36
37  $('#forecast .forecast.current .pressurestate .data').html('todo');
38  $('#forecast .forecast.current .winddirection .data').html(degToCompass(data.current_observation.wind.direction));
39  $('#forecast .forecast.current .windspeed .data').html(data.current_observation.wind.speed + 'km/h');
40
41  console.log(data.forecasts[1]);
42
43  $('#forecast .forecast.summary.1 h4').html(data.forecasts[1].day);
44  $('#forecast .forecast.summary.1 .tempdetail .temp-low .data').html(data.forecasts[1].low);
45  $('#forecast .forecast.summary.1 .tempdetail .temp-high .data').html(data.forecasts[1].high);
46  $('#forecast .forecast.summary.1 .weather .icon-font i').html(getWeatherIcon(data.forecasts[1].code));
47  $('#forecast .forecast.summary.1 .weather .description').html(data.forecasts[1].text);
48
49  $('#forecast .forecast.summary.2 h4').html(data.forecasts[2].day);
50  $('#forecast .forecast.summary.2 .tempdetail .temp-low .data').html(data.forecasts[2].low);
51  $('#forecast .forecast.summary.2 .tempdetail .temp-high .data').html(data.forecasts[2].high);
52  $('#forecast .forecast.summary.2 .weather .icon-font i').html(getWeatherIcon(data.forecasts[2].code));
53  $('#forecast .forecast.summary.2 .weather .description').html(data.forecasts[2].text);
54
55  $('#forecast .forecast.summary.3 h4').html(data.forecasts[3].day);
56  $('#forecast .forecast.summary.3 .tempdetail .temp-low .data').html(data.forecasts[3].low);
57  $('#forecast .forecast.summary.3 .tempdetail .temp-high .data').html(data.forecasts[3].high);
58  $('#forecast .forecast.summary.3 .weather .icon-font i').html(getWeatherIcon(data.forecasts[3].code));
59  $('#forecast .forecast.summary.3 .weather .description').html(data.forecasts[3].text);
60
61  $('#forecast .forecast.summary.4 h4').html(data.forecasts[4].day);
62  $('#forecast .forecast.summary.4 .tempdetail .temp-low .data').html(data.forecasts[4].low);
63  $('#forecast .forecast.summary.4 .tempdetail .temp-high .data').html(data.forecasts[4].high);
64  $('#forecast .forecast.summary.4 .weather .icon-font i').html(getWeatherIcon(data.forecasts[4].code));
65  $('#forecast .forecast.summary.4 .weather .description').html(data.forecasts[4].text);
66
67
68    var state;
69    switch (parseInt(data.current_observation.atmosphere.rising)) {
70        case 1:
71            state = '<span class="rising"><span>Rising</span></span>';
72            break;
73        case 2:
74            state = '<span class="falling"><span>Falling</span></span>';
75            break;
76        default:
77            state = '<span class="steady"><span>Steady</span></span>'
78    }
79    $("#forecast .forecast.current .pressurestate .data").html(state);
80
81}).
82  done(function() {
83      $('#weather-widget').show();
84  });
85
86
87
88
89
90$.get( "?getTides&location=" + weatherLoc + "", function( data ) {
91
92  var e = [];
93  $.each(data.Turns, function() {
94      var t = this.Minute,
95          i = t / 60,
96          n = Math.floor(i),
97          o = Math.round(60 * (i - n));
98      10 > o && (o = "0" + o);
99      var s = !0;
100      n > 12 && (n -= 12, s = !1), 12 == n && (s = !1);
101      var r = n + ":" + o + (s ? "am" : "pm"),
102          a = this.Date,
103          l = parseInt(a.substring(0, 4)),
104          h = parseInt(a.substring(4, 6)),
105          c = parseInt(a.substring(6, 8));
106      a = (new Date).setFullYear(l, h - 1, c);
107      var p = (new Date).setHours(0, 0, 0, 0),
108          d = Math.floor((a - p) / 1e3 / 60 / 60 / 24);
109      e[d] || (e[d] = {
110          low: [],
111          high: []
112      }), "L" == this.HorL ? e[d].low.push(r) : e[d].high.push(r)
113  })
114
115
116
117  $('#forecast .forecast.current .tide-low .data').html(e[0].low.join(", "));
118  $('#forecast .forecast.current .tide-high .data').html(e[0].high.join(", "));
119
120  $('#forecast .forecast.summary.1 .tide-low .data').html(e[1].low.join(", "));
121  $('#forecast .forecast.summary.1 .tide-high .data').html(e[1].high.join(", "));
122
123  $('#forecast .forecast.summary.2 .tide-low .data').html(e[2].low.join(", "));
124  $('#forecast .forecast.summary.2 .tide-high .data').html(e[2].high.join(", "));
125
126  $('#forecast .forecast.summary.3 .tide-low .data').html(e[3].low.join(", "));
127  $('#forecast .forecast.summary.3 .tide-high .data').html(e[3].high.join(", "));
128
129  $('#forecast .forecast.summary.4 .tide-low .data').html(e[4].low.join(", "));
130  $('#forecast .forecast.summary.4 .tide-high .data').html(e[4].high.join(", "));
131
132
133});
134
135
136
137function getWeather(location){
138
139
140}
141
142
143
144
145  function getWeatherIcon(code) {
146      var icon;
147      switch (parseInt(code)) {
148          case 0:
149          case 2:
150          case 23:
151          case 24:
152              icon = "&#xe000;";
153              break;
154          case 3:
155          case 4:
156          case 37:
157          case 38:
158          case 39:
159          case 45:
160          case 47:
161              icon = "&#xe001;";
162              break;
163          case 32:
164          case 34:
165          case 36:
166              icon = "&#xe002;";
167              break;
168          case 7:
169          case 13:
170          case 14:
171          case 15:
172          case 16:
173          case 41:
174          case 42:
175          case 43:
176          case 46:
177              icon = "&#xe003;";
178              break;
179          case 5:
180          case 6:
181          case 8:
182          case 18:
183              icon = "&#xe004;";
184              break;
185          case 1:
186          case 9:
187          case 11:
188          case 12:
189          case 40:
190              icon = "&#xe005;";
191              break;
192          case 31:
193              var i = !0;
194              (new Date).getHours() > 18 && (i = !1), e = i ? "&#xe002;" : "&#xe006;";
195              break;
196          case 33:
197              icon = "&#xe006;";
198              break;
199          case 25:
200              icon = "&#xe008;";
201              break;
202          case 10:
203          case 17:
204          case 35:
205              icon = "&#xe009;";
206              break;
207          case 26:
208          case 44:
209              icon = "&#xe00a;";
210              break;
211          case 28:
212          case 30:
213              icon = "&#xe00b;";
214              break;
215          case 27:
216          case 29:
217              icon = "&#xe00c;";
218              break;
219          case 19:
220          case 20:
221          case 21:
222          case 22:
223          case 3200:
224              icon = "&#xe007;";
225              break;
226          default:
227              icon = "&#xe007;"
228      }
229      return icon
230  }
231
232
233
234
235  function convertMinsToHrsMins(mins) {
236    let h = Math.floor(mins / 60);
237    let m = mins % 60;
238    h = h < 10 ? '0' + h : h;
239    m = m < 10 ? '0' + m : m;
240    return `${h}:${m}`;
241  }
242
243
244  function degToCompass(num) {
245    var val = Math.floor((num / 22.5) + 0.5);
246    var arr = ["N", "NE", "NE", "NE", "E", "SE", "SE", "SE", "S", "SW", "SW", "SW", "W", "NW", "NW", "NW"];
247    return arr[(val % 16)];
248  }
249
250
251});

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.