common-utils JavaScript Library

website·Indexed 30 days ago

https://common-utils.js.org/

A utility library providing the Coordinate and CoordinateUtils classes for high-precision geographic coordinate system conversions between BD09, GCJ02, and WGS84. The library includes tools for DOM manipulation, asynchronous loading, cookie management, and AJAX requests.

Tokens
39.8K
Snippets
464
Records
548
Agent score
34%

What's inside common-utils

  1. Convert coordinates between BD09, GCJ02, and WGS84 systems

    The CoordinateUtils class provides static methods to transform coordinates between the Baidu (BD09), State Bureau of Surveying and Mapping (GCJ02/Mars), and WGS84 coordinate systems. For GCJ02 transformations, iterative methods can be used to reduce precision loss, potentially reaching an accuracy of 0.1 meters after one iteration.
  2. Convert between BD09, GCJ02, and WGS84 coordinate systems

    The CoordinateUtils class provides static methods to transform coordinates between the Baidu (BD09), Mars (GCJ02), and WGS84 coordinate systems. For GCJ02 conversions, iterative transformation can be used to reduce precision loss, potentially reaching an accuracy of 0.1 meters after one iteration.
  3. Transform coordinates between BD09, GCJ02, and WGS84

    The CoordinateUtils class provides static methods to convert coordinates between different geographic systems. For GCJ02 transformations, iterative methods can be used to reduce precision loss, potentially reaching 0.1-meter accuracy with one iteration.
  4. Convert coordinates using CoordinateUtils

    The CoordinateUtils class provides a set of static methods to transform coordinates between three major systems: BD09 (Baidu), GCJ02 (Mars/China Geodetic Coordinate System 2000), and WGS84. For GCJ02 conversions, the utility supports iterative processing to reduce precision loss; a single iteration can achieve approximately 0.1-meter accuracy.
  5. Transform coordinates between BD09, GCJ02, and WGS84

    The CoordinateUtils class provides static methods to convert coordinates between different geographic systems. For GCJ02 transformations, iterative processing can be used to reduce precision loss, potentially reaching an accuracy of 0.1 meters per iteration.
  6. Convert coordinates between BD09, GCJ02, and WGS84 systems

    The CoordinateUtils class provides static methods to transform coordinates between different systems. For GCJ02 conversions, iterative processes can be used to reduce precision loss, potentially reaching an accuracy of 0.1 meters after one iteration.
  7. Format dates and timestamps

    The library provides two functions for date handling: formatDatetime for converting a date to a formatted string, and formatTimestamp for converting a date to a 13-digit numeric timestamp.
    const date = new Date();
    
    // Format as string: YYYY-MM-DD HH:mm:ss
    const strDate = formatDatetime(date, 'YYYY-MM-DD HH:mm:ss');
    
    // Format as 13-digit timestamp
    const numDate = formatTimestamp(date);
  8. Inject inline styles into a document

    Use injectStyle(style, doc) to add inline CSS styles to a Document object. It returns the created HTMLStyleElement.
  9. Generate random unique identifiers (UUIDs)

    The library provides several functions to generate random IDs consisting of alphanumeric characters or digits:

    • getUuid8(options): Generates an 8-character alphanumeric ID.
    • getUuid16(options): Generates a 16-character alphanumeric ID.
    • getUuid(len, options): Generates an alphanumeric ID of length len (defaults to 32).
    • getUuidDigit(len, options): Generates a numeric-only ID of length len (defaults to 4).
  10. Compare top-level domains of two URLs

    Use isSameDomain(targetUrl, source) to check if two URLs share the same top-level domain. If targetUrl is empty or source is omitted, it defaults to the current local hostname.
    const url = 'http://localhost:8080/getList?id=12';
    const isSome = isSameDomain(url);
    console.log('Domains match:', isSome);
  11. Remove CSS classes from a DOM element

    Use removeClassName(el, className) to remove specific CSS classes from a DOM element. The className parameter accepts an array of strings.
    removeClassName(element, ['class1', 'class2']);
  12. Remove CSS classes from multiple DOM objects

    The removeClassNameByClassName(className, doc) function removes a specific class from multiple DOM objects within the provided document. It returns the affected HTMLElement or null.