Commit 736ea71e authored by Max Bebök's avatar Max Bebök

#54 added regex search to actor-search

parent 83c582a4
......@@ -64,6 +64,7 @@
}
#searchWindow-actor .data-searchValue {
width: calc(100% - 60px);
margin-bottom: 5px;
}
......@@ -93,6 +94,12 @@
border-style: solid;
color: #73c990;
}
#searchWindow-actor .btn-regex {
margin-top: 1px;
height: 29px;
}
</style>
<div>
<div class="search-header">
......@@ -100,7 +107,10 @@
Actor-Search
</div>
<div>
<input type="text" class="form-control data-searchValue" placeholder="Search for actors..." />
<input type="text" class="form-control data-searchValue" placeholder='Search...' />
<div class="btn-group">
<button class="btn btn-default btn-regex" data-filter="regex">Regex</button>
</div>
</div>
<div>
<div class="btn-group">
......
......@@ -18,10 +18,6 @@ module.exports = class Actor_Search_Finder
{
searchValue = searchValue.toLowerCase();
console.warn("SEARCH");
console.log(filter);
console.log(searchValue);
this.result = [];
for(const actorId in this.actorHandler.actors)
{
......@@ -52,18 +48,22 @@ module.exports = class Actor_Search_Finder
if(filter.srt && actor.getSRTHash() == searchValue)
return true;
let textToCompare = null;
if(filter.name)
{
const nameNorm = actor.getName().toLowerCase();
if(nameNorm.includes(searchValue))
return true;
}
textToCompare = actor.getName().toLowerCase();
if(filter.params)
textToCompare = JSON.stringify(params).toLowerCase();
if(textToCompare != null)
{
const paramStr = JSON.stringify(params).toLowerCase();
if(paramStr.includes(searchValue))
return true;
try{
return (filter.regex)
? new RegExp(searchValue).test(textToCompare)
: textToCompare.includes(searchValue);
}catch(e)
{}
}
return false;
......
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