Compare commits

...

4 Commits

Author SHA1 Message Date
697978420e Merge pull request 'fix #9' (#15) from NightFox/HLRTest:master into master
Reviewed-on: #15
2024-02-16 01:30:17 +01:00
2f4cf5c3be title for filter 2024-02-16 02:40:39 +03:00
3da9283b42 bonus ALT+F for focus at filter input 2024-02-16 02:38:37 +03:00
a25dee6640 fix #9 2024-02-16 02:27:50 +03:00

View File

@ -212,19 +212,24 @@ function buildData(table, images, data, sort, filter, exact_match) {
data = filterData(data);
}
if (filter) {
if (exact_match) {
data = data.filter((d) => {
const test = d.test === filter;
const channel = d.channel === filter;
return test || channel;
});
let test = "", channel = "";
const args = filter.split(" ");
if (args.length > 1) {
test = args[0];
channel = args[1]
} else {
data = data.filter((d) => {
const test = d.test.includes(filter);
const channel = d.channel.includes(filter);
return test || channel;
});
test = filter;
channel = filter;
}
data = data.filter((d) => {
const test_result = exact_match ? d.test === test : d.test.includes(test);
const channel_result = exact_match ? d.channel === channel : d.channel.includes(channel);
if (args.length > 1) {
return test_result && channel_result;
} else {
return test_result || channel_result;
}
});
}
table.replaceChildren(...buildTestResultsTable(data));
@ -560,7 +565,7 @@ window.onload = () => {
Tag("div", {"class": "panel", "id": "table"}, null, [
Tag("h2", null, "List of things that are not perfect"),
Tag("label", {"class": "filter sticky"}, "Filter", [
filter = Tag("input", {"type": "input", "name": "filter", "value": filter_value}, null, null, "input", (e) => {
filter = Tag("input", {"type": "input", "title": "Hotkey: ALT+F", "name": "filter", "value": filter_value}, null, null, "input", (e) => {
saveToLocalStorage("rendertest_filter", e.target.value);
buildDataSlowMode(table, images, data, tableSort, e.target.value, exactmatch_input.checked);
}),
@ -666,6 +671,16 @@ window.onload = () => {
}
}
});
document.addEventListener("keydown", function(event) {
if (event.altKey) {
if (event.key === 'f') {
event.preventDefault();
filter.focus();
}
}
});
}