Skip to content

Instantly share code, notes, and snippets.

@elight
Created February 1, 2012 19:31
Show Gist options
  • Save elight/1718794 to your computer and use it in GitHub Desktop.
Save elight/1718794 to your computer and use it in GitHub Desktop.
this.tagSearcher = {
// Assuming that the user is only appending to the text, search up to X words back
// for permutations that match a hash key on TagList
lookup: function() {
var lastThree = this.text.split(this.whiteSpaceRegexp).reverse().splice(2);
var phrase = "";
$.each(lastThree, function(index, word) {
phrase = word + phrase;
if(TagList.get(phrase) !== null) {
return phrase;
}
phrase = " " + phrase;
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment