[Search] Comments and style

This commit is contained in:
shale 2015-07-16 16:54:53 -07:00
parent cf3169dd68
commit c82163fa7b

View File

@ -40,7 +40,7 @@ define(function () {
$scope.page = $scope.results.slice(start, start + howMany); $scope.page = $scope.results.slice(start, start + howMany);
} }
function getResults(inputID) { function search(inputID) {
// Later, the search result format will be different // Later, the search result format will be different
// Will need to compile search result list (for this // Will need to compile search result list (for this
@ -55,7 +55,7 @@ define(function () {
return { return {
// Search the database using the user input of id "searchinput" // Search the database using the user input of id "searchinput"
search: getResults, search: search,
// Check to see if there are any search results to display. // Check to see if there are any search results to display.
areResults: function () { areResults: function () {
@ -71,14 +71,17 @@ define(function () {
return $scope.results.length > $scope.page.length; return $scope.results.length > $scope.page.length;
}, },
// Check to see if are items such that we can go back a page
canGoBack: function () { canGoBack: function () {
return $scope.index > 0; return $scope.index > 0;
}, },
// Check to see if are items such that we can go forward a page
canGoForward: function () { canGoForward: function () {
return ($scope.index + $scope.pageLength) < $scope.results.length; return ($scope.index + $scope.pageLength) < $scope.results.length;
}, },
// Change the items in scope to be the ones in the next page
nextPage: function (howMany) { nextPage: function (howMany) {
if (!howMany) { if (!howMany) {
howMany = $scope.pageLength; howMany = $scope.pageLength;
@ -88,6 +91,7 @@ define(function () {
$scope.page = $scope.results.slice($scope.index, $scope.index + howMany); $scope.page = $scope.results.slice($scope.index, $scope.index + howMany);
}, },
// Change the items in scope to be the ones in the previous page
previousPage: function (howMany) { previousPage: function (howMany) {
if (!howMany) { if (!howMany) {
howMany = $scope.pageLength; howMany = $scope.pageLength;