Warning: Undefined array key "yPBFjS" in /home/ic3/domains/ic3.info/public_html/wp-includes/kses.php on line 1
HEX
HEX
Server: LiteSpeed
System: Linux control5.webnow.vn 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: ic3 (1169)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /home/ic3/public_html/wp-content/plugins/school-management/assets/js/modules/utils.js
/**
 * Utility functions for School Management
 */
window.SchoolManagement = window.SchoolManagement || {};

window.SchoolManagement.Utils = {
  /**
   * Sort text naturally (handles numbers in text)
   * @param {Object} a - First object with title property
   * @param {Object} b - Second object with title property
   * @returns {number} Sort comparison result
   */
  naturalSort: function (a, b) {
    const aTitle = a.title.toLowerCase();
    const bTitle = b.title.toLowerCase();

    return aTitle.localeCompare(bTitle, undefined, {
      numeric: true,
      sensitivity: "base",
    });
  },

  /**
   * Sort arrays by post_title property naturally
   * @param {Array} array - Array to sort
   * @returns {Array} Sorted array
   */
  sortByTitle: function (array) {
    return array.sort(function (a, b) {
      return a.post_title.localeCompare(b.post_title, undefined, {
        numeric: true,
        sensitivity: "base",
      });
    });
  },

  /**
   * Create AJAX request with proper headers
   * @param {Object} options - AJAX options
   * @returns {jqXHR} jQuery AJAX object
   */
  createAjaxRequest: function (options) {
    const $ = window.SchoolManagement.$ || jQuery;
    const defaultOptions = {
      beforeSend: function (xhr) {
        xhr.setRequestHeader("X-WP-Nonce", schoolManagementAjax.nonce);
      },
    };

    return $.ajax($.extend(defaultOptions, options));
  },
};