code: function getCandidates (querystr) {
          candidates = [];
          if (querystr === '' || !querystr) {
              for (var i = 0; i < items.length; i++) {
                  candidates.push({text: items[i], matched: items[i]});
              }
          } else {
              var splitQueryString = querystr.split(" ");
              var escapedQueryString = escapeRegExp(querystr);
              for (var x = 0; x < items.length; x++) {
                  var item = items[x];
                  // if item matches full query string, push it to the list of 
                  // candidates. 
                  // if not, test on partials
                  var reg = new RegExp(escapedQueryString, 'gi');
                  if (reg.test(item)) {
                      candidates.push({
                          text: item,
                          matched: item.replace(reg, '{DELIMITER}{MATCH}{DELIMITER}$&{DELIMITER}{NOMATCH}{DELIMITER}')
                      });
                  } else {
                      // escape each piece of the split query string
                      // then join together with pipes
                      // and then do a test/replace on that
                      var escapedSplitQueryString = "";
                      splitQueryString.forEach(function(qs) {
                          var escaped = escapeRegExp(qs);
                          if (escapedSplitQueryString) escapedSplitQueryString = escapedSplitQueryString + "|" + escaped;
                          else escapedSplitQueryString = escaped;
                      });
                      var splitReg = new RegExp(escapedSplitQueryString, 'gi');
                      if (splitReg.test(item)) {
                          candidates.push({
                              text: item,
                              matched: item.replace(splitReg, '{DELIMITER}{MATCH}{DELIMITER}$&{DELIMITER}{NOMATCH}{DELIMITER}')
                          });
                      }
                  }
              }
          }
          return candidates;
      }
docs: /*  Get Candidates function
  Basically all the search/filter stuff for the autocomplete
  2 different methods of searching
  - first search is on entire search string. These matches take priority
  - second search is on partial search string, split on spaces
  For example, lets say users searches for "charm fun".
  An entry that contains the string "charm fun" is a higher-scoring match.
  However, we will also show entries that either have "charm" or "fun"
  ==============================================================================