[~] Refactor

This commit is contained in:
Siarhei Siniak 2024-08-12 22:59:56 +03:00
parent d782fbfbf2
commit 633e1c6424

@ -364,6 +364,66 @@ const online_fxreader_linkedin = new Linkedin();
entries.empty(); entries.empty();
} }
let keywords = self.state.search.split(/\s+/).map((o) => {
let action = null;
let word = null;
if (o.length > 0)
{
if (o[0] == '-')
{
action = 'include';
word = o.slice(1,);
}
else if (o[0] == '+')
{
action = 'exclude';
word = o.slice(1,);
}
else
{
action = 'include';
word = o;
}
}
return {
action,
word,
};
}).filter((o) => o.action !== nul);
let filtered_entries = sorted_entries.filter((o) => {
let match = true;
let text = JSON.stringify(o);
for (let k of keywords)
{
if (k.action == 'include')
{
if (text.search(text) == -1)
{
match = false;
}
}
else if (k.action == 'exclude')
{
if (text.search(text) != -1)
{
match = false;
}
}
if (!match)
{
break;
}
}
return match;
})
for (let o of sorted_entries.reverse()) for (let o of sorted_entries.reverse())
{ {
let raw = JSON.stringify(o[1]); let raw = JSON.stringify(o[1]);