Commit f60091c6 authored by Themousaillon's avatar Themousaillon

Adding keyword filter

parent fb12369c
This diff is collapsed.
......@@ -117,9 +117,11 @@ function start(settings, login, password) {
html += '<button type="button" class="btn btn-light" id="' + id + '-b_none">none</button>';
html += '<button type="button" class="btn btn-light" id="' + id + '-b_invert">invert</button>';
html += '</span>';
default:
break;
default:
}
if (option.label === 'content')
html += '<input id="' + id + '" type="text" value="" aria-label="keyword" placeholder="Enter keyword">'
$('#filters-container').append(html);
}
});
......@@ -161,6 +163,8 @@ function start(settings, login, password) {
});
break;
}
if (option.label === 'content')
document.getElementById(id).addEventListener('change', () => { app.updateFilter(); });
}
});
......
......@@ -193,7 +193,6 @@ module.exports = function () {
Frame.prototype.getFilter = function () {
let filter = {};
this.app.settings.source.properties.forEach((property) => {
let option = this.app.settings.source.options[property];
let id = "filter-" + option.label;
......@@ -227,6 +226,15 @@ module.exports = function () {
});
break;
}
if (option.label === "content"){
let elem = document.getElementById(id);
if (elem) {
filter["keywords"] = {
type: "content",
keywords: elem.value.split(" ")
}
}
}
}
});
......
......@@ -96,7 +96,6 @@ module.exports = (function () {
Node.prototype.filterResource = function (resource, globalFilter) {
let filter = this.filter()!==undefined? this.filter() : globalFilter;
let properties = Object.keys(filter);
return properties.every((property) => {
let f = filter[property];
......@@ -116,6 +115,8 @@ module.exports = (function () {
} else if (i == -1 && !f.checked[f.categories.indexOf('others')]){
return false;
};
case 'content':
return f.keywords === "" ? true : f.keywords.every(keyword => resource.content.toLowerCase().includes(keyword))
default:
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment