PageSourceSearch

https://bitbank.nz/static/js/webutils.js

js bitbank.nz collected 2026-10-03 20:47:58 UTC 2,836 bytes, 90 lines download raw bytes

1window.webutils = (function () {
2    var self = {};
3
4    var loadingElToIconMap = {};
5    self.setIconLoading = function (el) {
6        var $el = $(el);
7        loadingElToIconMap[el] = $el.find('i').attr('class');
8        $el.attr('disabled', 'disabled')
9            .find('i').attr('class', 'fa fa-spinner fa-spin');
10    };
11    self.setIconDone = function (el) {
12        var $el = $(el);
13        $el.removeAttr('disabled')
14            .find('i').attr('class', loadingElToIconMap[el]);
15        delete loadingElToIconMap[$el];
16    };
17
18    self.urlencode = function (name) {
19        return name.replace(/\s/g, '-')
20            .replace(/[\.\t\,\:;\(\)'@!\\\?#/<>&]/g, '')
21            .replace(/[^\x00-\x7F]/g, "")
22            .toLowerCase();
23    };
24
25    self.uid = (function () {
26        function s4() {
27            return Math.floor((1 + Math.random()) * 0x10000)
28                .toString(36)
29                .substring(1);
30        }
31
32        return function () {
33            return s4() + s4();
34        };
35    })();
36
37    return self;
38})();
39
40// Lightweight production frontend error reporting for the local monitor.
41(function () {
42    'use strict';
43    var endpoint = '/api/frontend-errors';
44    var sent = 0;
45    var maxPerPage = 8;
46
47    function post(payload) {
48        if (sent >= maxPerPage || !payload) return;
49        sent += 1;
50        payload.url = window.location.href;
51        payload.user_agent = navigator.userAgent;
52        payload.timestamp = new Date().toISOString();
53        try {
54            var body = JSON.stringify(payload);
55            if (navigator.sendBeacon) {
56                var blob = new Blob([body], { type: 'application/json' });
57                if (navigator.sendBeacon(endpoint, blob)) return;
58            }
59            fetch(endpoint, {
60                method: 'POST',
61                headers: { 'Content-Type': 'application/json' },
62                body: body,
63                keepalive: true,
64                credentials: 'same-origin',
65            }).catch(function () {});
66        } catch (err) {}
67    }
68
69    window.addEventListener('error', function (event) {
70        post({
71            type: 'error',
72            message: event.message || (event.error && event.error.message) || 'window error',
73            stack: event.error && event.error.stack ? String(event.error.stack) : '',
74            source: event.filename || '',
75            line: event.lineno || 0,
76            column: event.colno || 0,
77        });
78    });
79
80    window.addEventListener('unhandledrejection', function (event) {
81        var reason = event.reason || {};
82        post({
83            type: 'unhandledrejection',
84            message: reason.message ? String(reason.message) : String(reason),
85            stack: reason.stack ? String(reason.stack) : '',
86        });
87    });
88})();
89
90// nunjucks.configure({ autoescape: true });

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.