[Search] Comments

This commit is contained in:
shale 2015-07-15 10:22:03 -07:00
parent 3420eb69d3
commit 227cb42ba7

View File

@ -48,10 +48,10 @@ define(
function itemsHelper(children, i) { function itemsHelper(children, i) {
var composition; var composition;
if (i >= children.length) { if (i >= children.length) {
// Base case, is a leaf // Done!
return children; return children;
} else if (children[i].hasCapability('composition')) { } else if (children[i].hasCapability('composition')) {
// Handle this child's children // This child has children
composition = children[i].getCapability('composition'); composition = children[i].getCapability('composition');
return composition.invoke().then(function (grandchildren) { return composition.invoke().then(function (grandchildren) {
// Add grandchildren to the end of the list // Add grandchildren to the end of the list
@ -59,6 +59,7 @@ define(
return itemsHelper(children.concat(grandchildren), i + 1); return itemsHelper(children.concat(grandchildren), i + 1);
}); });
} else { } else {
// This child is a leaf
return itemsHelper(children, i + 1); return itemsHelper(children, i + 1);
} }
} }
@ -68,13 +69,14 @@ define(
function getItems() { function getItems() {
// Aquire My Items (root folder) // Aquire My Items (root folder)
return objectService.getObjects(['mine']).then(function (objects) { return objectService.getObjects(['mine']).then(function (objects) {
// Get all of its descendents
return itemsHelper([objects.mine], 0).then(function (c) { return itemsHelper([objects.mine], 0).then(function (c) {
return c; return c;
}); });
}); });
} }
// Search through items for items manually // Search through filetree for items manually
// This is a fallback if other search services aren't avaliable // This is a fallback if other search services aren't avaliable
function queryManual(inputID, maxResults) { function queryManual(inputID, maxResults) {
var term, var term,
@ -87,8 +89,7 @@ define(
// Check to see if the user provided a maximum // Check to see if the user provided a maximum
// number of results to display // number of results to display
if (!maxResults) { if (!maxResults) {
// Else, we provide a default value. This is an // Else, we provide a default value.
// arbitrary big number.
maxResults = DEFAULT_MAX_RESULTS; maxResults = DEFAULT_MAX_RESULTS;
} }