[Search] Comments

This commit is contained in:
slhale
2015-07-30 15:00:28 -07:00
parent 15b7e3ac9b
commit f8471bc944
2 changed files with 7 additions and 14 deletions

View File

@ -48,9 +48,10 @@ define(
// array, and returns the number that were removed. // array, and returns the number that were removed.
function filterDuplicates(results, total) { function filterDuplicates(results, total) {
var ids = [], var ids = [],
numRemoved = 0; numRemoved = 0,
i;
for (var i = 0; i < results.length; i += 1) { for (i = 0; i < results.length; i += 1) {
if (ids.indexOf(results[i].id) !== -1) { if (ids.indexOf(results[i].id) !== -1) {
// If this result's ID is already there, remove the object // If this result's ID is already there, remove the object
results.splice(i, 1); results.splice(i, 1);

View File

@ -35,14 +35,6 @@ define(function () {
var numResults = INITIAL_LOAD_NUMBER, var numResults = INITIAL_LOAD_NUMBER,
fullResults = []; fullResults = [];
/*
// Function to be passed to the search service which allows it to set the
// search template's results list
function setControllerResults(results) {
$scope.results = results.slice(0, numResults);
}
*/
function search() { function search() {
var inputText = $scope.ngModel.input; var inputText = $scope.ngModel.input;
@ -57,9 +49,7 @@ define(function () {
numResults = INITIAL_LOAD_NUMBER; numResults = INITIAL_LOAD_NUMBER;
// Send the query // Send the query
//searchService.sendQuery(inputText, setControllerResults);
searchService.query(inputText).then(function (result) { searchService.query(inputText).then(function (result) {
//console.log('controller - results', results);
fullResults = result.hits; fullResults = result.hits;
$scope.results = result.hits.slice(0, numResults); $scope.results = result.hits.slice(0, numResults);
}); });
@ -95,7 +85,8 @@ define(function () {
* Checks to see if there are more search results to display. * Checks to see if there are more search results to display.
*/ */
areMore: function () { areMore: function () {
return numResults < fullResults.length;//searchService.getNumResults(); return numResults < fullResults.length;
// TODO: See loadMore() todo.
}, },
/** /**
@ -105,7 +96,8 @@ define(function () {
loadMore: function () { loadMore: function () {
numResults += LOAD_INCREMENT; numResults += LOAD_INCREMENT;
$scope.results = fullResults.slice(0, numResults); $scope.results = fullResults.slice(0, numResults);
//searchService.refresh(setControllerResults); // TODO: Let load more see if total > fullResults.length, and then
// if so, resend a query.
} }
}; };
} }