//search by name:
final ByNameSearcher byNameSearcher = new ByNameSearcher(util, "");
final Node byNameInput = byName.appendChild("<input type=\"text\" value=\"\"></input>");
AutoComplete ac = Y.newAutoComplete(AutoCompleteConfig.create().
resultHighlighter("phraseMatch").
inputNode(byNameInput).
source(byNameSearcher.autocompleteData()).
render(true)
);
Y.newButton(ButtonConfig.create().label("Search").
on("click", new EventCallback<ButtonEvent>() {
@Override
public void call(ButtonEvent e) {
String keyword = byNameInput.get("value");
byNameSearcher.setName(keyword);
JsArray<Module> results = SearchUtil.search(util.getModules(), byNameSearcher);
console.log("search by name keyword: "+keyword+", results: "+results.length());
resultTable.data(results);
resultTable.render();
}
})).render(byName);
//search by tags
final ByTagsSearcher byTagsSearcher = new ByTagsSearcher(util, "");
final Node byTagsInput = byTag.appendChild("<input type=\"text\" value=\"\"></input>");
AutoComplete acTags = Y.newAutoComplete(AutoCompleteConfig.create().
resultHighlighter("phraseMatch").
inputNode(byTagsInput).
source(byTagsSearcher.autocompleteData()).
render(true)
);
Y.newButton(ButtonConfig.create().label("Search").
on("click", new EventCallback<ButtonEvent>() {
@Override
public void call(ButtonEvent e) {
String keyword = byTagsInput.get("value");
byTagsSearcher.setTag(keyword);
JsArray<Module> results = SearchUtil.search(util.getModules(), byTagsSearcher);
console.log("search by tag keyword: "+keyword+", results: "+results.length());
resultTable.data(results);
resultTable.render();
}
})).render(byTag);
//search by requires
final ByRequiresSearcher byRequiresSearcher = new ByRequiresSearcher(util, "");
final Node byRequiresInput = byRequires.appendChild("<input type=\"text\" value=\"\"></input>");
AutoComplete acRequires = Y.newAutoComplete(AutoCompleteConfig.create().
resultHighlighter("phraseMatch").
inputNode(byRequiresInput).
source(byRequiresSearcher.autocompleteData()).
render(true)
);