Namespace for IITC utils
Members
-
static, constant MAX_LATITUDE :Number
-
The maximum absolute latitude that can be represented in Web Mercator projection (EPSG:3857). This value is taken from L.Projection.SphericalMercator.MAX_LATITUDE
Methods
-
private, static clamp(n, max, min) → {number}
-
Clamps a given value between a minimum and maximum value. Simple implementation for internal use.
Parameters:
Name Type Description n
number The value to clamp.
max
number The maximum allowed value.
min
number The minimum allowed value.
Returns:
number -The clamped value.
-
static clampLatLng(latlng) → {Array.<number>}
-
Clamps a latitude and longitude to the maximum and minimum valid values.
Parameters:
Name Type Description latlng
L.LatLng The latitude and longitude to clamp.
Returns:
Array.<number> -The clamped latitude and longitude.
-
static clampLatLngBounds(bounds) → {L.LatLngBounds}
-
Clamps a latitude and longitude bounds to the maximum and minimum valid values.
Parameters:
Name Type Description bounds
L.LatLngBounds The bounds to clamp.
Returns:
L.LatLngBounds -The clamped bounds.
-
static deleteCookie(name)
-
Deletes a cookie by name.
Parameters:
Name Type Description name
string The name of the cookie to delete.
-
static escapeHtml(str) → {string}
-
Escapes HTML special characters in a string.
Parameters:
Name Type Description str
string The string to escape.
Returns:
string -The escaped string.
-
static escapeJS(str) → {string}
-
Escapes special characters in a string for use in JavaScript. (for strings passed as parameters to html onclick="..." for example)
Parameters:
Name Type Description str
string The string to escape.
Returns:
string -The escaped string.
-
static formatAgo(time, now, optionsopt) → {string}
-
Formats the time difference between two timestamps (in milliseconds) as a string.
Parameters:
Name Type Attributes Description time
number The past timestamp in milliseconds.
now
number The current timestamp in milliseconds.
options
Object <optional>
Options for formatting.
Properties
Name Type Attributes Default Description showSeconds
boolean <optional>
false Whether to include seconds in the result.
Returns:
string -The formatted time difference (e.g., "45s", "5m", "2h 45m", "1d 3h 45m")
-
static formatDistance(distance) → {string}
-
Formats a distance in meters, converting to kilometers with appropriate precision based on the distance range.
For distances:
- Under 1000m: shows in meters, rounded to whole numbers
- 1000m to 9999m: shows in kilometers with 1 decimal place
- 10000m and above: shows in whole kilometers
Parameters:
Name Type Description distance
number The distance in meters.
Returns:
string -The formatted distance.
-
static formatInterval(seconds, maxTermsopt) → {string}
-
Formats an interval of time given in seconds into a human-readable string.
Parameters:
Name Type Attributes Description seconds
number The interval in seconds.
maxTerms
number <optional>
The maximum number of time units to include.
Returns:
string -The formatted time interval.
-
static formatNumber(num) → {string}
-
Formats a number with thousand separators (thin spaces). see https://en.wikipedia.org/wiki/Space_(punctuation)#Table_of_spaces
Parameters:
Name Type Description num
number The number to format.
Returns:
string -The formatted number with thousand separators.
-
static genFourColumnTable(blocks) → {string}
-
Generates a four-column HTML table from an array of data blocks.
Parameters:
Name Type Description blocks
Array Array of data blocks, where each block is an array with details for one row.
Returns:
string -HTML string representing the constructed table.
-
static getCookie(name) → {string|undefined}
-
Retrieves the value of a cookie by name.
Parameters:
Name Type Description name
string The name of the cookie to retrieve.
Returns:
string | undefined -The value of the cookie, or undefined if not found.
-
static getURLParam(param) → {string}
-
Retrieves a parameter from the URL query string.
Parameters:
Name Type Description param
string The name of the parameter to retrieve.
Returns:
string -The value of the parameter, or an empty string if not found.
-
static isPointInPolygon(polygon, point) → {boolean}
-
Determines if a point is inside a polygon.
Parameters:
Name Type Description polygon
Array.<L.LatLng> The vertices of the polygon.
point
L.LatLng The point to test.
Returns:
boolean -True if the point is inside the polygon, false otherwise.
-
static isTouchDevice() → {boolean}
-
Checks if the device is a touch-enabled device. Alias for
L.Browser.touch()
Returns:
boolean -True if the device is touch-enabled, otherwise false.
-
static prettyEnergy(nrg) → {string|number}
-
Formats the energy of a portal, converting to "k" units if over 1000.
Parameters:
Name Type Description nrg
number The energy value to format.
Returns:
string | number -The formatted energy value.
-
static scrollBottom(elm) → {number}
-
Calculates the number of pixels left to scroll down before reaching the bottom of an element.
Parameters:
Name Type Description elm
string | HTMLElement | jQuery The element or selector to calculate the scroll bottom for.
Returns:
number -The number of pixels from the bottom.
-
static setCookie(name, value, daysopt)
-
Sets a cookie with a specified name and value, with a default expiration of 10 years.
Parameters:
Name Type Attributes Default Description name
string The name of the cookie.
value
string The value of the cookie.
days
number <optional>
3650 Optional: the number of days until the cookie expires (default is 10 years).
-
static textToTable(text) → {string}
-
Converts text with newlines (
\n
) and tabs (\t
) into an HTML table.Parameters:
Name Type Description text
string The text to convert.
Returns:
string -The resulting HTML table.
-
static uniqueArray(arr) → {Array}
-
Converts a list of items into a unique array, removing duplicates.
Parameters:
Name Type Description arr
Array The array to process.
Returns:
Array -A new array containing only unique elements.
-
static unixTimeToDateTimeString(time, millisecondopt) → {string|null}
-
Converts a UNIX timestamp to a precise date and time string in the local timezone. Formatted in ISO-style YYYY-MM-DD hh:mm:ss.mmm - but using local timezone.
Parameters:
Name Type Attributes Description time
number The UNIX timestamp to convert.
millisecond
boolean <optional>
Whether to include millisecond precision.
Returns:
string | null -The formatted date and time string.
-
static unixTimeToHHmm(time) → {string|null}
-
Converts a UNIX timestamp to a time string formatted as HH:mm.
Parameters:
Name Type Description time
number | string The UNIX timestamp to convert.
Returns:
string | null -Formatted time as HH:mm.
-
static unixTimeToString(timestamp, fullopt) → {string|null}
-
Converts a UNIX timestamp to a human-readable string. If the timestamp is from today, returns the time (HH:mm:ss format); otherwise, returns the date (YYYY-MM-DD).
Parameters:
Name Type Attributes Default Description timestamp
number | string The UNIX timestamp in milliseconds to convert.
full
boolean <optional>
false If true, returns both date and time in "YYYY-MM-DD
" format. Returns:
string | null -The formatted date and/or time string, or null if no timestamp provided.
-
static zeroPad(number, length) → {string}
-
Pads a number with zeros up to a specified length.
Parameters:
Name Type Description number
number The number to pad.
length
number The desired length of the output string.
Returns:
string -The padded number as a string.