Jump to content

Search the Community

Showing results for tags 'sizzle'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I needed a quick and dirty approach to splitting up jQuery multiple selectors, so I could record if a selector pattern had already been used. So I came up with this "quick 'n' dirty" hack. If someone can up with better let me know. I tried to look at the sizzle source, but didn't have enough time to plough through 2000 lines of code. // Split the following multiple selectors into an array var selector = '#nav-bar-temp-1 a, #nav-bar-temp-2 a'; console.log(getSelectors(selector)); /** * Get a list of selectors (singule or multiple) * * @param {string} selector A valid jQuery selector string * @returns {array} An array or selectors; otherwise, an empty array */ function getSelectors(selector) { var isInQuoteMark = false, // True/false when inside a quotation mark i.e. commas should be ignored isNextSelector = false, // If passed a comma set to true, so whitespace can be escaped before meeting a next non-whitespace character isQuoteMark = false, // True/false as to whether a quotation mark reQuoteMark = /[\"\']/, // Regex to determine a quotation mark selectors = [], // Array to hold found selectors temporary = ''; // Temp variable to store the selector for (var i = 0, length = selector.length; i < length; i++) { // Is it a quotation mark? isQuoteMark = selector[i].match(reQuoteMark); if (isQuoteMark && !isInQuoteMark) { // Appears to be the start of a string isInQuoteMark = true; } else if (isQuoteMark && isInQuoteMark) { // Appears to be the end of a string isInQuoteMark = false; } else if (selector[i] === ',' && !isInQuoteMark) { // If a comma and not inside a string then push to the array isNextSelector = true; selectors.push(temporary); temporary = ''; // So as not to add the comma to the temporary variable continue; } else if (selector[i] !== ' ' && isNextSelector) { // If not an empty space but the next selector has started then set to false isNextSelector = false; } // If the character can be concatanated i.e. not whitespace after a comma, then add if (!isNextSelector) { temporary += selector[i]; } } // If temporary is not empty, then push to the array if (temporary) { selectors.push(temporary); } // Return the array of selectors. Note it could be empty return selectors; }
×
×
  • Create New...