PageSourceSearch

https://pawtul.com/static/js/global.js

js pawtul.com collected 2026-10-02 01:39:13 UTC 5,533 bytes, 187 lines download raw bytes

1function downloadUrl(url, callback) {
2
3    var xmlhttp = new XMLHttpRequest();
4
5    xmlhttp.onreadystatechange = function () {
6        if (this.readyState == 4 && this.status == 200) {
7            try {
8                var myArr = JSON.parse(this.responseText);
9                callback(myArr, this.status);
10            } catch (e) {
11                // console.error('Failed to parse JSON response:', e);
12                callback(null, this.status);
13            }
14        }
15    };
16    xmlhttp.open("GET", url, true);
17    xmlhttp.send();
18    xmlhttp.onerror = function () {
19        console.log("Request failed");
20    };
21}
22
23// function sendDataUrl(url, data2Send, callback) {
24
25//     var xmlhttp = new XMLHttpRequest();
26
27//     xmlhttp.onreadystatechange = function () {
28//         if (this.readyState == 4 && this.status == 200) {
29//             var myArr = JSON.parse(this.responseText);
30//             callback(myArr, this.status)
31//         }
32//     };
33
34//     xmlhttp.open('POST', url)
35//     xmlhttp.setRequestHeader("Content-Type", "application/json");
36//     xmlhttp.onload = function () {
37//         console.log('Upload response status:', xmlhttp.status);
38//         console.log('Response:', xmlhttp.responseText);
39//     };
40//     xmlhttp.onerror = function () {
41//         console.log('It appears the file is too large');
42//     };
43//     xmlhttp.send(data2Send);
44// }
45
46function sendDataUrl(url, data2Send, callback) {
47    var xmlhttp = new XMLHttpRequest();
48
49    xmlhttp.open('POST', url);
50    xmlhttp.setRequestHeader("Content-Type", "application/json");
51
52    xmlhttp.onload = function () {
53        // console.log('Upload response status:', xmlhttp.status);
54        // console.log('Response:', xmlhttp.responseText);
55
56        if (xmlhttp.status === 200) {
57            var myArr = JSON.parse(xmlhttp.responseText);
58            callback(myArr, xmlhttp.status);
59        } else {
60            console.error('Server responded with error:', xmlhttp.status);
61        }
62    };
63
64    xmlhttp.onerror = function () {
65        console.error('Upload failed. Could be file size or server crash.');
66    };
67
68    xmlhttp.send(data2Send);
69}
70
71
72function doNothing() { }
73
74function formatDate(dateInfo) {
75    const today = new Date(dateInfo);
76    y = today.getFullYear();
77    m = today.getMonth() + 1;
78    if (m < 10) {
79        m = '0' + m;
80    }
81    d = today.getDate();
82    if (d < 10) {
83        d = '0' + d;
84    }
85    hh = today.getHours();
86    if (hh < 10) {
87        hh = '0' + hh;
88    }
89    mm = today.getMinutes();
90    if (mm < 10) {
91        mm = '0' + mm;
92    }
93
94    return y + '-' + m + '-' + d + ' ' + hh + ':' + mm;
95
96}
97
98function b64toBlob(b64Data, contentType) {
99    const sliceSize = 512;
100    const byteCharacters = atob(b64Data);
101    const byteArrays = [];
102    for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
103        const slice = byteCharacters.slice(offset, offset + sliceSize);
104
105        const byteNumbers = new Array(slice.length);
106        for (let i = 0; i < slice.length; i++) {
107            byteNumbers[i] = slice.charCodeAt(i);
108        }
109
110        const byteArray = new Uint8Array(byteNumbers);
111        byteArrays.push(byteArray);
112    }
113
114    const blob = new Blob(byteArrays, { type: contentType });
115    return blob;
116}
117
118function ValidateEmail(inputText) {
119    var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
120    if (inputText.value.match(mailformat)) {
121        // alert("Valid email address!");
122        // document.form1.text1.focus();
123        return true;
124    }
125    else {
126        // alert("You have entered an invalid email address!");
127        document.getElementById(inputText.id).focus();
128        return false;
129    }
130}
131
132// function getSelectValues(select) {
133//     var result = [];
134//     var options = select && select.options;
135//     var opt;
136
137//     for (var i=0, iLen=options.length; i<iLen; i++) {
138//       opt = options[i];
139
140//       if (opt.selected) {
141//         result.push(opt.value || opt.text);
142//       }
143//     }
144//     return result;
145//   }
146
147function getSelectValues(select) {
148    var result = [];
149    var options = select && select.options;
150    var opt;
151
152    for (var i = 0, iLen = options.length; i < iLen; i++) {
153        opt = options[i];
154
155        if (opt.selected) {
156            result.push(opt.value || opt.text);
157        }
158    }
159    return result.join();
160}
161
162function sortDates_yyyy_mm_dd(sent_Date) {
163    // get the year, month, and day components of the date in the GMT/BST time zone
164    const year = sent_Date.getUTCFullYear();
165    const month = sent_Date.getUTCMonth() + 1; // add 1 to get 1-based month (January is 1)
166    const day = sent_Date.getUTCDate();
167
168    // calculate the local time by adding the time zone offset to the UTC time
169    const localDate = new Date(sent_Date.getTime() - (sent_Date.getTimezoneOffset() * 60000));
170
171    // get the year, month, and day components of the local date
172    const localYear = localDate.getFullYear();
173    const localMonth = localDate.getMonth() + 1; // add 1 to get 1-based month (January is 1)
174    const localDay = localDate.getDate();
175
176    // format the components into a string with the desired format
177    const dateString = `${localYear}-${localMonth.toString().padStart(2, '0')}-${localDay.toString().padStart(2, '0')}`;
178    return dateString
179}
180
181function formatDateYMD(date) {
182    const yyyy = date.getFullYear();
183    const mm = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed, so we add 1
184    const dd = String(date.getDate()).padStart(2, '0');
185
186    return `${yyyy}-${mm}-${dd}`;
187}

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.