2018-07-29 16:11:48 +02:00
|
|
|
exports.get_search_terms = function (input) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const search_terms = input.toLowerCase().split(",").map(function (s) {
|
2018-07-29 16:11:48 +02:00
|
|
|
return s.trim();
|
|
|
|
});
|
|
|
|
return search_terms;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.vanilla_match = function (opts) {
|
|
|
|
/*
|
|
|
|
This is a pretty vanilla search criteria
|
|
|
|
where we see if any of our search terms
|
|
|
|
is in our value. When in doubt we should use
|
|
|
|
this for all Zulip filters, but we may
|
|
|
|
have more complicated use cases in some
|
|
|
|
places.
|
|
|
|
|
|
|
|
This is case insensitive.
|
|
|
|
*/
|
2019-11-02 00:06:25 +01:00
|
|
|
const val = opts.val.toLowerCase();
|
2018-07-29 16:11:48 +02:00
|
|
|
return _.any(opts.search_terms, function (term) {
|
|
|
|
if (val.indexOf(term) !== -1) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-10-25 09:45:13 +02:00
|
|
|
window.search_util = exports;
|