[Search] Getting input text

The controller now gets the input text from the
DOM element ID, then passes that string along
to the search service, instead of passing the
raw ID.
This commit is contained in:
shale 2015-07-23 16:10:03 -07:00
parent 7d495f6389
commit 33e8084852
4 changed files with 16 additions and 21 deletions

View File

@ -125,7 +125,7 @@ define(
}
// For documentation, see sendQuery below.
function queryAll(inputID, timestamp) {
function queryAll(inputText, timestamp) {
// If there's not a timestamp, make this time the timestamp
if (!timestamp) {
var date = new Date();
@ -134,7 +134,7 @@ define(
// Send the query to all the providers
for (var i = 0; i < providers.length; i += 1) {
providers[i].query(inputID, timestamp, DEFAULT_MAX_RESULTS, DEFUALT_TIMEOUT);
providers[i].query(inputText, timestamp, DEFAULT_MAX_RESULTS, DEFUALT_TIMEOUT);
}
// Update the merged results list
@ -146,8 +146,7 @@ define(
* Sends a query to each of the providers, then updates the global
* latestMergedResults accordingly.
*
* @param inputID The name of the ID property of the html text
* input where this funcion should find the search term.
* @param inputText The text input that is the query.
* @param timestamp (optional) The time at which this function
* was called. This timestamp will be associated with the
* latest results list, which allows us to see if it has been

View File

@ -70,13 +70,14 @@ define(function () {
function search(inputID) {
var date = new Date(),
timestamp = date.getTime();
timestamp = date.getTime(),
inputText = document.getElementById(inputID).value;
// Reset 'load more'
numResults = INITIAL_LOAD_NUMBER;
// Send the query
searchService.sendQuery(inputID, timestamp);
searchService.sendQuery(inputText, timestamp);
update(timestamp);
}
@ -101,6 +102,10 @@ define(function () {
}
},
/**
* Checks to see if we are still waiting for the results to be
* fully updated.
*/
isLoading: function () {
return loading;
},

View File

@ -145,9 +145,8 @@ define(
}
// For documentation, see query below.
function queryElasticsearch(inputID, timestamp, maxResults, timeout) {
var searchTerm,
esQuery;
function queryElasticsearch(searchTerm, timestamp, maxResults, timeout) {
var esQuery;
// Check to see if the user provided a maximum
// number of results to display
@ -156,9 +155,6 @@ define(
maxResults = DEFAULT_MAX_RESULTS;
}
// Get the user input
searchTerm = document.getElementById(inputID).value;
// If the user input is empty, we want to have no search results.
if (searchTerm !== '') {
// Process search term
@ -198,7 +194,7 @@ define(
* * More search details at
* https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html
*
* @param inputID the name of the ID property of the html text
* @param searchTerm The text input that is the query.
* input where this funcion should find the search term
* @param timestamp the time at which this function was called,
* this timestamp will be associated with the latest results

View File

@ -158,9 +158,8 @@ define(
}
// For documentation, see query below.
function queryGeneric(inputID, timestamp, maxResults, timeout) {
var input,
terms = [],
function queryGeneric(input, timestamp, maxResults, timeout) {
var terms = [],
searchResults = [],
resultsLength;
@ -171,9 +170,6 @@ define(
maxResults = DEFAULT_MAX_RESULTS;
}
// Get the user input
input = document.getElementById(inputID).value;
// Get items list
return getItems(timeout).then(function () {
// Then get the worker to search through it
@ -195,8 +191,7 @@ define(
* * Scores are higher for matches that have more than one of
* the terms as substrings.
*
* @param inputID the name of the ID property of the html text
* input where this funcion should find the search term
* @param input The text input that is the query.
* @param timestamp the time at which this function was called,
* this timestamp will be associated with the latest results
* list, which allows the aggregator to see if it has been