Created
February 26, 2014 00:04
-
-
Save kmaglione/9220650 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConvertTermsToURI: function(terms) { | |
// Create an array to hold each search term | |
var termArray = new Array(); | |
// Split up the search term string based on the space character | |
termArray = terms.split(" "); | |
// Call the DoEncode function on each item in our array | |
termArray.forEach(this.DoEncode); | |
// Join the array with the plus sign and return the result | |
return termArray.join("+"); | |
}, | |
//////////////////////////////////////////////////////////////////////////// | |
// The DoEncode() function gets called on an array of search terms. Each | |
// incoming term is encoded, for use in a URL. | |
//////////////////////////////////////////////////////////////////////////// | |
DoEncode: function(element, index, array) { | |
// Modify the array element by calling encodeURIComponent on it | |
array[index] = encodeURIComponent(element); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment