B2G/gaia/apps/communications/contacts/js/fb/fb_link.js
//  do not work properly with words with special characters (bug 796714)
do not work properly with words with special characters (bug 796714)
do not work properly with words with special characters ( bug 796714 )
function searchAccents(searchArrays, contactData) {
      var out = [];
      var searchFields = Object.keys(SEARCH_ACCENTS_FIELDS);
      function compareItems(target, item) {
        var out;
        if (typeof target === 'string') {
          out = target.localeCompare(item);
          if (out !== 0) {
            if (item.indexOf(target) === 0) {
              out = 0;
            }
          }
        }
        return out;
      } 
      searchFields.forEach(function(searchField) {
        var searchArray = searchArrays[searchField].sort(function(a, b) {
          return a[searchField].localeCompare(b[searchField]);
        });
        var fieldToSearch = contactData[SEARCH_ACCENTS_FIELDS[searchField]];
        if (fieldToSearch && fieldToSearch[0]) {
          var dataToSearch = fieldToSearch[0].trim().split(/[ ]+/);
          dataToSearch.forEach(function(aData) {
            var targetString = Normalizer.toAscii(aData).toLowerCase();
            var searchResult = utils.binarySearch(targetString, searchArray, {
              arrayField: searchField,
              compareFunction: compareItems
            });
            searchResult.forEach(function(aResult) {
              var candidate = searchArray[aResult].originalIndex;
              if (out.indexOf(candidate) === -1) {
                out.push(candidate);
              }
            });
          });
        }
      });
      return out;
    }
function searchAccents ( searchArrays , contactData ) { var out = [ ] ; var searchFields = Object . keys ( SEARCH_ACCENTS_FIELDS ) ; function compareItems ( target , item ) { var out ; if ( typeof target === 'string' ) { out = target . localeCompare ( item ) ; if ( out !== 0 ) { if ( item . indexOf ( target ) === 0 ) { out = 0 ; } } } return out ; } searchFields . forEach ( function ( searchField ) { var searchArray = searchArrays [ searchField ] . sort ( function ( a , b ) { return a [ searchField ] . localeCompare ( b [ searchField ] ) ; } ) ; var fieldToSearch = contactData [ SEARCH_ACCENTS_FIELDS [ searchField ] ] ; if ( fieldToSearch && fieldToSearch [ 0 ] ) { var dataToSearch = fieldToSearch [ 0 ] . trim ( ) . split ( / [ ]+ / ) ; dataToSearch . forEach ( function ( aData ) { var targetString = Normalizer . toAscii ( aData ) . toLowerCase ( ) ; var searchResult = utils . binarySearch ( targetString , searchArray , { arrayField : searchField , compareFunction : compareItems } ) ; searchResult . forEach ( function ( aResult ) { var candidate = searchArray [ aResult ] . originalIndex ; if ( out . indexOf ( candidate ) === - 1 ) { out . push ( candidate ) ; } } ) ; } ) ; } } ) ; return out ; }
do not work properly with words with special characters (bug 796714)
do not work properly with words with special characters ( bug 796714 )
// compareItems Function // The array is ordered according to the search field // this enables an efficient binary search // Splitting in the different words // Avoiding to show two times the same result element