Permalink
Browse files

remove dependency on strtr

  • Loading branch information...
1 parent f61dbec commit 2aa4d61464c49565bfe194795a2e522fb5eb9c69 @jpmckinney jpmckinney committed Apr 13, 2013
Showing with 3 additions and 5 deletions.
  1. +3 −5 core/AbstractSpellcheckWidget.js
@@ -3,8 +3,6 @@
/**
* Interacts with Solr's SpellCheckComponent.
*
- * <p>Requires <tt>String#strtr</tt> defined in <tt>ajaxsolr.support.js</tt>.
- *
* @see http://wiki.apache.org/solr/SpellCheckComponent
*
* @class AbstractSpellcheckWidget
@@ -29,11 +27,11 @@ AjaxSolr.AbstractSpellcheckWidget = AjaxSolr.AbstractWidget.extend(
* @returns {String} A suggested query.
*/
suggestion: function () {
- var replacePairs = {};
+ var suggestion = this.manager.response.responseHeader.params['spellcheck.q'];
for (var word in this.suggestions) {
- replacePairs[word] = this.suggestions[word][0];
+ suggestion = suggestion.replace(new RegExp(word, 'g'), this.suggestions[word][0]);
}
- return this.manager.response.responseHeader.params['spellcheck.q'].strtr(replacePairs);
+ return suggestion;
},
beforeRequest: function () {

0 comments on commit 2aa4d61

Please sign in to comment.