function parseFilter_(filterText) {
    // Assemble a list of quoted and unquoted strings in the filter.
    var filterList = [];
    var position = 0;
    while (position < filterText.length) {
      var inQuote = false;
      var filterElement = '';
      var negated = false;
      var startPosition = position;
      while (position < filterText.length) {
        var nextCharacter = filterText[position];
        ++position;
        if (nextCharacter == '\\' && position < filterText.length) {
          // If there's a backslash, skip the backslash and add the next
          // character to the element.
          filterElement += filterText[position];
          ++position;
          continue;
        } else if (nextCharacter == '"') {
          // If there's an unescaped quote character, toggle |inQuote| without
          // modifying the element.
          inQuote = !inQuote;
        } else if (!inQuote && /\s/.test(nextCharacter)) {
          // If not in a quote and have a whitespace character, that's the
          // end of the element.
          break;
        } else if (nextCharacter == '-' && startPosition == position - 1) {
          // If this is the first character, and it's a '-', this entry is
          // negated.
          negated = true;
        } else {
          // Otherwise, add the next character to the element.
          filterElement += nextCharacter;
        }
      }

      if (filterElement.length > 0) {
        var filter = {
          parsed: filterElement.toLowerCase(),
          original: filterText.substring(startPosition, position),
          negated: negated,
        };
        filterList.push(filter);
      }
    }
    return filterList;
  }
/**
   * Takes in the text of a filter and returns a list of
   * {parsed, original, negated} values that correspond to substrings of the
   * filter before and after filtering, and whether or not it started with a
   * '-'.  Extra whitespace other than a single character after each element is
   * ignored.  Parsed strings are all lowercase.
   */
Takes in the text of a filter and returns a list of
{parsed, original, negated} values that correspond to substrings of the
filter before and after filtering, and whether or not it started with a
'-'.  Extra whitespace other than a single character after each element is
ignored.  Parsed strings are all lowercase.
Takes in the text of a filter and returns a list of { parsed original negated } values that correspond to substrings of the filter before and after filtering and whether or not it started with a ' - ' . Extra whitespace other than a single character after each element is ignored . Parsed strings are all lowercase .
function parseFilter_(filterText) {
    var filterList = [];
    var position = 0;
    while (position < filterText.length) {
      var inQuote = false;
      var filterElement = '';
      var negated = false;
      var startPosition = position;
      while (position < filterText.length) {
        var nextCharacter = filterText[position];
        ++position;
        if (nextCharacter == '\\' && position < filterText.length) {
          filterElement += filterText[position];
          ++position;
          continue;
        } else if (nextCharacter == '"') {
          inQuote = !inQuote;
        } else if (!inQuote && /\s/.test(nextCharacter)) {
          break;
        } else if (nextCharacter == '-' && startPosition == position - 1) {
          negated = true;
        } else {
          filterElement += nextCharacter;
        }
      }
      if (filterElement.length > 0) {
        var filter = {
          parsed: filterElement.toLowerCase(),
          original: filterText.substring(startPosition, position),
          negated: negated,
        };
        filterList.push(filter);
      }
    }
    return filterList;
  }
function parseFilter_ ( filterText ) { var filterList = [ ] ; var position = 0 ; while ( position < filterText . length ) { var inQuote = false ; var filterElement = '' ; var negated = false ; var startPosition = position ; while ( position < filterText . length ) { var nextCharacter = filterText [ position ] ; ++ position ; if ( nextCharacter == '\\' && position < filterText . length ) { filterElement += filterText [ position ] ; ++ position ; continue ; } else if ( nextCharacter == '"' ) { inQuote = ! inQuote ; } else if ( ! inQuote && / \s / . test ( nextCharacter ) ) { break ; } else if ( nextCharacter == '-' && startPosition == position - 1 ) { negated = true ; } else { filterElement += nextCharacter ; } } if ( filterElement . length > 0 ) { var filter = { parsed : filterElement . toLowerCase ( ) , original : filterText . substring ( startPosition , position ) , negated : negated , } ; filterList . push ( filter ) ; } } return filterList ; }
Takes in the text of a filter and returns a list of
 {parsed, original, negated} values that correspond to substrings of the
 filter before and after filtering, and whether or not it started with a
 '-'.
Takes in the text of a filter and returns a list of { parsed original negated } values that correspond to substrings of the filter before and after filtering and whether or not it started with a ' - ' .
// Assemble a list of quoted and unquoted strings in the filter. // If there's a backslash, skip the backslash and add the next // character to the element. // If there's an unescaped quote character, toggle |inQuote| without // modifying the element. // If not in a quote and have a whitespace character, that's the // end of the element. // If this is the first character, and it's a '-', this entry is // negated. // Otherwise, add the next character to the element.