PageSourceSearch

https://backoffice.israelgives.org/assets/javascripts/forms/errors-handler.js?version=8.942

js israelgives.org collected 2026-09-24 18:15:38 UTC 1,703 bytes, 47 lines download raw bytes

1function GetLanguage() {
2    if (window.location.href.indexOf("/en/") > 0) {
3        return "en";
4    }
5    else {
6        return "he";
7    }
8}
9
10// String.replace with a string pattern replaces only the FIRST match, so an error
11// mentioning more than one tag used to reach /LogError as raw HTML, ASP.NET request
12// validation rejected it and the POST 500'd before anything was written to the log.
13// Replace globally, neutralise numeric entities too, and cap the length so a multi-KB
14// dump (a failed Kendo template, for instance) does not fill the log row.
15function SanitizeErrorText(text) {
16    var safe = (text === null || text === undefined ? "" : String(text))
17        .replace(/</g, "{")
18        .replace(/>/g, "}")
19        .replace(/&#/g, "&{");
20    return safe.length > 2000 ? safe.substring(0, 2000) + " ...[truncated]" : safe;
21}
22
23function PostError(exception) {
24    try {
25        var logUrl = "/en/LogError";
26        var message = '';
27        if (exception.error) {
28            message = SanitizeErrorText(exception.error.message + " " + (exception.error.stack ? exception.error.stack.toString() : ""));
29        }
30        else {
31            message = SanitizeErrorText(exception.message);
32        }
33
34        var url = window.location.href;        
35        $.ajax({
36            url: logUrl,
37            type: 'POST',
38            data: { message: message ? message : "unknown" , url: url ? url : "unknown" }
39        });    
40        console.log('****** Error found and logged = ' + message + " url: " + url);
41    }
42    catch (error) {
43        console.log(error);
44    }
45}
46
47window.addEventListener('error', function (event) { PostError(event); });

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.