diff hip.js @ 14:a26372118854

Created a primitive form of noun-first suggestion.
author jonathandicarlo@localhost
date Wed, 02 Jul 2008 16:50:15 -0700
parents 8dcc88f93829
children 5fce4c8f3ebd
line wrap: on
line diff
--- a/hip.js	Wed Jul 02 12:04:46 2008 -0700
+++ b/hip.js	Wed Jul 02 16:50:15 2008 -0700
@@ -70,88 +70,9 @@
 
 };
 
-function QuerySource(verbList) {
-  this._init(verbList);
-}
-QuerySource.prototype = {
-  _init: function(verbList) {
-    this._verbList = verbList; //arrayof Verb objects to use for completions
-    this._lockedInSentence = null;
-    this._hilitedSuggestion = 0;
-    this._suggestionList = []; // a list of ParsedSentences.
-  },
 
-  updateSuggestionList: function( query ) {
-    this._suggestionList = [];
-    var completions = [];
-    var words = query.split( " " );
-    for ( var x in this._verbList ) {
-      var verb = this._verbList[x];
-      if ( verb.match( words[0] ) ) {
-	completions = verb.getCompletions( words.slice(1) );
-	this._suggestionList = this._suggestionList.concat( completions );
-      }
-    }
-    // TODO sort in order of match quality
-    this._hilitedSuggestion = 1; // hilight the first suggestion by default
-  },
-
-  getSuggestionsAsHtml : function() {
-    return [ this._suggestionList[x].getDisplayText() for ( x in this._suggestionList ) ];
-  },
-
-  getDescriptionText: function() {
-    if ( this._suggestionList.length == 0 ) {
-      return "You got the magic stick. Type some commands!";
-    }
-    var h = this._hilitedSuggestion;
-    if ( h == 0 ) {
-      return "Executes your input literally, with no autocompletion.";
-    } else {
-      h = h - 1;
-    }
-    var sentence = this._suggestionList[h];
-    return sentence.getDescription();
-  },
-
-  indicationDown: function( ) {
-    this._hilitedSuggestion ++;
-    if ( this._hilitedSuggestion > this._suggestionList.length ) {
-      this._hilitedSuggestion = 0;
-      }
-  },
-
-  indicationUp: function() {
-    this._hilitedSuggestion --;
-    if ( this._hilitedSuggestion < 0 ) {
-      this._hilitedSuggestion = this._suggestionList.length;
-      }
-  },
-
-  getHilitedSuggestion: function() {
-    return this._hilitedSuggestion - 1; // because 0 means no hilite
-    // and the suggestion list starts at 1... fencepost!
-  },
-
-  autocomplete: function( query ) {
-    var newText;
-    var hilited = this.getHilitedSuggestion();
-    if ( hilited > -1 ) {
-      newText = this._suggestionList[ hilited ].getCompletionText() + " ";
-    } else {
-      newText = query;
-    }
-    return newText;
-  },
-
-  clear: function() {
-    this._suggestionList = [];
-    this._hilitedSuggestion = 0;
-    this._lockedInSentence = null;
-  }
-};
-
-var gQs = new QuerySource([ fly, define, google, go, close, open, translate, email, nuke, encrypt, wiki ]);
+var gQs = new QuerySource([ fly, define, google, go, close, open, translate, email, nuke, encrypt, wiki ],
+			  [city, language, tab, person, application]);
 
 function makeSuggestionHtml( tagName, list, hilitedNumber ) {
   var result = "";