PageSourceSearch

https://www.nzherald.co.nz/pf/resources/scripts/nzme.js?d=1068

js nzherald.co.nz collected 2026-09-24 07:39:38 UTC 2,225 bytes, 65 lines download raw bytes

1(function () {
2  const NZME = window.NZME || {};
3
4  NZME.debugOn = flag => {
5    switch (flag) {
6      case true: // act as setter to enable debugging
7        window?.localStorage?.setItem("nzmeDebug", "y");
8        return true;
9      case false: // act as setter to disable debugging
10        window?.localStorage?.removeItem("nzmeDebug");
11        return false;
12      default: // assume undefined, so act as getter
13        return !!window?.localStorage?.getItem("nzmeDebug");
14    }
15  };
16
17  NZME.debug = (...args) => {
18    try {
19      // conditional logging
20      if (NZME.debugOn()) {
21        console.log(JSON.stringify(args, Object.getOwnPropertyNames(args)));
22      }
23    } catch (e) {
24      console.log("NZME.debug error:", e);
25    }
26  };
27
28  /**
29   * Listen to a custom event.
30   * @param {string} eventName: label that identifies the event type
31   * @param {function} listener: takes an event object with an (optional) detail property.
32   * @return {function} takes no params, unsubscribes this listener.
33   */
34  NZME.subscribe = (eventName, listener) => {
35    window.addEventListener(eventName, listener);
36    return () => window.removeEventListener(eventName, listener);
37  };
38
39  /**
40   * Broadcast an event to any listeners on window or document.
41   * Events are dispatched on document (for older browsers) but can bubble up.
42   * @param {string} eventName: label that identifies the event type
43   * @param {*} detail (optional) a payload to pass to the listener(s).
44   */
45  NZME.publish = (eventName, detail) => {
46    if (typeof CustomEvent === "function") {
47      const publication = new CustomEvent(eventName, { detail, bubbles: true });
48      window.document.dispatchEvent(publication);
49    } else if (typeof Event === "function") {
50      const publication = new Event(eventName, { bubbles: true });
51      publication.detail = detail;
52      window.document.dispatchEvent(publication);
53    } else {
54      // Support older browsers
55      const publication = document.createEvent("Event");
56      publication.initEvent(eventName, true, false);
57      publication.detail = detail;
58      window.document.dispatchEvent(publication);
59    }
60
61    NZME.debug([Date.now(), eventName, detail]);
62  };
63
64  window.NZME = NZME;
65})();

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.