"<li id=\"search1-by-tag\"><b class=\"label\">by tags: </b><br/></li>" +
"<li id=\"search1-by-requires\"><b class=\"label\">by required modules: </b><br/></li>" +
"</ul>"+
"<div id=\"search1-result-container\"></div>"
);
Node byName = parent.one("#search1-by-name");
Node byTag = parent.one("#search1-by-tag");
Node byRequires = parent.one("#search1-by-requires");
resultContainer = parent.one("#search1-result-container");
//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)
);
Y.newButton(ButtonConfig.create().label("Search").
on("click", new EventCallback<ButtonEvent>() {
@Override
public void call(ButtonEvent e) {
String keyword = byRequiresInput.get("value");
byRequiresSearcher.setRequire(keyword);
JsArray<Module> results = SearchUtil.search(util.getModules(), byRequiresSearcher);
console.log("search by Requires keyword: "+keyword+", results: "+results.length());
resultTable.data(results);
resultTable.render();