2021-01-23 16:38:13 +00:00
|
|
|
|
2021-01-24 03:58:53 +00:00
|
|
|
function applyQuery(items, query) {
|
|
|
|
return items.filter(query.filter, query).sort(query.compare);
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayItems(items_copy) {
|
|
|
|
let items_parent = document.getElementById("main");
|
|
|
|
for (let i in items_copy) {
|
|
|
|
let item = items_copy[i];
|
|
|
|
let box = document.createElement("div");
|
|
|
|
box.classList.add("box");
|
|
|
|
box.id = "item"+i;
|
|
|
|
items_parent.appendChild(box);
|
|
|
|
displayExpandedItem(expandItem(item, []), box.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-24 10:09:59 +00:00
|
|
|
function doItemSearch() {
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
let input_json = document.getElementById("query-json").value;
|
|
|
|
let input = JSON.parse(input_json);
|
|
|
|
let items_copy = items.slice();
|
|
|
|
document.getElementById("main").textContent = "";
|
|
|
|
for (const _query of input) {
|
|
|
|
const query = queryTypeMap.get(_query.queryType)(_query.value);
|
|
|
|
items_copy = applyQuery(items_copy, query);
|
|
|
|
}
|
|
|
|
document.getElementById("summary").textContent = items_copy.length + " results."
|
|
|
|
displayItems(items_copy);
|
|
|
|
}
|
|
|
|
|
2021-01-23 16:38:13 +00:00
|
|
|
function init() {
|
2021-01-24 10:09:59 +00:00
|
|
|
return;
|
2021-01-23 16:38:13 +00:00
|
|
|
let items_copy = items.slice();
|
2021-01-24 03:58:53 +00:00
|
|
|
//let query = new NameQuery("Bob's");
|
2021-01-24 10:09:59 +00:00
|
|
|
let query1 = new IdQuery("sdRaw");
|
2021-01-24 03:58:53 +00:00
|
|
|
items_copy = applyQuery(items_copy, query1);
|
|
|
|
|
2021-01-24 10:09:59 +00:00
|
|
|
let query2 = new TypeQuery("helmet");
|
2021-01-24 03:58:53 +00:00
|
|
|
items_copy = applyQuery(items_copy, query2);
|
|
|
|
|
|
|
|
displayItems(items_copy);
|
2021-01-23 16:38:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_init(init);
|