PageSourceSearch

https://kagoafrica.com/client/assets/js/utils.js?version=3.0.9.1

js kagoafrica.com collected 2026-09-24 14:15:42 UTC 2,146 bytes, 79 lines download raw bytes

1function convertTableToObjects(table, skipLastColumn = false) {
2    const headers = Array.from(table.querySelectorAll('th')).map(th => th.textContent);
3    if (skipLastColumn) {
4      headers.pop(); // remove the last header from the headers array
5    }
6    const rows = Array.from(table.querySelectorAll('tbody tr'));
7    
8    return rows.map(row => {
9      const data = Array.from(row.querySelectorAll('td')).map(td => td.textContent);
10      if (skipLastColumn) {
11        data.pop(); // remove the last item from the data array
12      }
13      return headers.reduce((obj, header, index) => ({ ...obj, [header]: data[index] }), {});
14    });
15  }
16
17  function prettifyDate(date) {
18    const dateObj = new Date(date);
19    const day = dateObj.getDate();
20    const month = dateObj.toLocaleString("default", { month: "short" });
21    const year = dateObj.getFullYear();
22    let hours = dateObj.getHours();
23    const minutes = dateObj.getMinutes();
24    let period = "AM";
25
26    // Convert 24-hour format to 12-hour format and determine AM/PM
27    if (hours >= 12) {
28        period = "PM";
29        if (hours > 12) {
30            hours -= 12;
31        }
32    }
33    if (hours === 0) {
34        hours = 12;
35    }
36    
37    // Pad single digit hours and minutes with leading zeros
38    const paddedHours = String(hours).padStart(2, '0');
39    const paddedMinutes = String(minutes).padStart(2, '0');
40    
41    const formattedDate = `${day}-${month}-${year} ${paddedHours}:${paddedMinutes} ${period}`;
42    
43    return formattedDate;
44}
45
46function formatErrorMessage(message) {
47    if (typeof message == 'string') {
48        return message
49    }
50
51    else {
52        let messageString = ''
53        message.forEach(errorMessage => {
54            messageString += errorMessage + "\n"
55        })
56
57        return messageString
58    }
59}
60
61function validateContainerNumber(containerNo) {
62  const regex = new RegExp(/^[a-zA-Z]{4}[0-9]{7}$/i);
63  
64  const result = regex.test(containerNo);
65
66  if (!result) {
67      return false;
68  }
69
70  return true;
71}
72
73function truncateString(string, limit) {
74  if (string.length < limit) {
75    return string;
76  }
77
78  return string.slice(0, limit) + "...";
79}

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.