diff options
author | Erik Kristensen <ekristen@pfsense.org> | 2005-08-23 01:18:28 +0000 |
---|---|---|
committer | Erik Kristensen <ekristen@pfsense.org> | 2005-08-23 01:18:28 +0000 |
commit | 8ab3e9ed14dc643d1f0192a67655b0691e083968 (patch) | |
tree | b8f31194997af46f303beaad8892b7173c19178c /usr/local/www/javascript/suggestions.js | |
parent | 1e055202d3b8e244e65188eb1d0b261fae0c5749 (diff) | |
download | pfsense-8ab3e9ed14dc643d1f0192a67655b0691e083968.zip pfsense-8ab3e9ed14dc643d1f0192a67655b0691e083968.tar.gz |
First Step in Fixing AutoComplete and Cleaning Up Code
Diffstat (limited to 'usr/local/www/javascript/suggestions.js')
-rw-r--r-- | usr/local/www/javascript/suggestions.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/usr/local/www/javascript/suggestions.js b/usr/local/www/javascript/suggestions.js new file mode 100644 index 0000000..1b30fff --- /dev/null +++ b/usr/local/www/javascript/suggestions.js @@ -0,0 +1,33 @@ + +/** + * Provides suggestions for state names (USA). + * @class + * @scope public + */ +function StateSuggestions(text) { + this.states = text; +} + +/** + * Request suggestions for the given autosuggest control. + * @scope protected + * @param oAutoSuggestControl The autosuggest control to provide suggestions for. + */ +StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/, + bTypeAhead /*:boolean*/) { + var aSuggestions = []; + var sTextboxValue = oAutoSuggestControl.textbox.value; + + if (sTextboxValue.length > 0){ + + //search for matching states + for (var i=0; i < this.states.length; i++) { + if (this.states[i].indexOf(sTextboxValue) == 0) { + aSuggestions.push(this.states[i]); + } + } + } + + //provide suggestions to the control + oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead); +};
\ No newline at end of file |