PageSourceSearch

https://parklandposse.com/js/staticnav.js?v=1.2

js parklandposse.com collected 2026-09-25 09:14:55 UTC 2,263 bytes, 43 lines download raw bytes

1// Static SSR navigation helpers for RAMPWebsites.
2//
3// The public site is migrating to static server-side rendering (no Blazor circuit),
4// so filter <select>s must drive navigation with plain JS. The site's CSP uses a
5// nonce + 'strict-dynamic' with NO 'unsafe-inline', which blocks inline on* handlers
6// (onchange="..."). This external file is nonce'd in App.razor, so it's allowed, and a
7// single delegated listener covers every static page (and is inert elsewhere).
8//
9//   <select data-nav>          option value is a full URL/path -> navigate on change
10//   <select data-autosubmit>   submit the enclosing GET form on change (query-param filter)
11(function () {
12    document.addEventListener('change', function (e) {
13        var el = e.target;
14        if (!el || el.tagName !== 'SELECT') return;
15
16        if (el.hasAttribute('data-nav')) {
17            if (el.value) window.location.href = el.value;
18        } else if (el.hasAttribute('data-autosubmit') && el.form) {
19            if (typeof el.form.requestSubmit === 'function') el.form.requestSubmit();
20            else el.form.submit();
21        }
22    }, false);
23})();
24
25// Calendar feed links (<a data-tz-feed> -> .ics subscribe/download) are rendered server-side without a
26// timezone. Stamp them with the browser's IANA timezone so the feed carries the subscriber's zone
27// (CalendarController ?TZ= -> VTIMEZONE/TZID; otherwise the .ics has floating times the client guesses).
28// The interactive page did this via Blazor JS interop; static SSR has no circuit, so augment on the client.
29(function () {
30    function applyFeedTimeZone() {
31        var tz;
32        try { tz = Intl.DateTimeFormat().resolvedOptions().timeZone || ''; } catch (e) { tz = ''; }
33        if (!tz) return;
34        var enc = encodeURIComponent(tz);
35        document.querySelectorAll('a[data-tz-feed]').forEach(function (a) {
36            var href = a.getAttribute('href');
37            if (!href || /[?&]TZ=/i.test(href)) return;
38            a.setAttribute('href', href + (href.indexOf('?') !== -1 ? '&' : '?') + 'TZ=' + enc);
39        });
40    }
41    if (document.readyState !== 'loading') applyFeedTimeZone();
42    else document.addEventListener('DOMContentLoaded', applyFeedTimeZone);
43})();

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.