mirror of
https://github.com/chaoticbackup/chaoticbackup.github.io.git
synced 2026-04-26 01:02:54 -05:00
search by name now excludes by ~
This commit is contained in:
parent
e14de59e88
commit
25a7eadf41
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -3559,9 +3559,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/react": {
|
"@types/react": {
|
||||||
"version": "16.9.38",
|
"version": "16.9.41",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.38.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.41.tgz",
|
||||||
"integrity": "sha512-pHAeZbjjNRa/hxyNuLrvbxhhnKyKNiLC6I5fRF2Zr/t/S6zS41MiyzH4+c+1I9vVfvuRt1VS2Lodjr4ZWnxrdA==",
|
"integrity": "sha512-6cFei7F7L4wwuM+IND/Q2cV1koQUvJ8iSV+Gwn0c3kvABZ691g7sp3hfEQHOUBJtccl1gPi+EyNjMIl9nGA0ug==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/prop-types": "*",
|
"@types/prop-types": "*",
|
||||||
"csstype": "^2.2.0"
|
"csstype": "^2.2.0"
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
"@babel/runtime": "^7.10.3",
|
"@babel/runtime": "^7.10.3",
|
||||||
"@types/chai": "^4.2.11",
|
"@types/chai": "^4.2.11",
|
||||||
"@types/mocha": "^7.0.2",
|
"@types/mocha": "^7.0.2",
|
||||||
"@types/react": "^16.9.38",
|
"@types/react": "^16.9.41",
|
||||||
"@types/react-dom": "^16.9.8",
|
"@types/react-dom": "^16.9.8",
|
||||||
"@types/react-router-dom": "^5.1.5",
|
"@types/react-router-dom": "^5.1.5",
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
|
|
|
||||||
|
|
@ -44,28 +44,50 @@ export default function search_api(input) {
|
||||||
|
|
||||||
// Search by name
|
// Search by name
|
||||||
if (input.name.length > 0) {
|
if (input.name.length > 0) {
|
||||||
let inputname = cleanInputRegex(input.name);
|
const negates = [];
|
||||||
|
let inputname = input.name.replace(/(?:~)([\w,()]+)/g, (_, p1) => { negates.push(p1); return ""; });
|
||||||
|
|
||||||
|
if (inputname.length > 0) {
|
||||||
|
inputname = cleanInputRegex(inputname);
|
||||||
|
|
||||||
|
attackResults = attackResults.find({ '$or': [
|
||||||
|
{ 'gsx$name': { '$regex': inputname }},
|
||||||
|
{ 'gsx$tags': { '$regex': inputname }},
|
||||||
|
]});
|
||||||
|
battlegearResults = battlegearResults.find({ '$or': [
|
||||||
|
{ 'gsx$name': { '$regex': inputname }},
|
||||||
|
{ 'gsx$tags': { '$regex': inputname }},
|
||||||
|
]});
|
||||||
|
creatureResults = creatureResults.find({ '$or': [
|
||||||
|
{ 'gsx$name': { '$regex': inputname }},
|
||||||
|
{ 'gsx$tags': { '$regex': inputname }},
|
||||||
|
]});
|
||||||
|
locationResults = locationResults.find({ '$or': [
|
||||||
|
{ 'gsx$name': { '$regex': inputname }},
|
||||||
|
{ 'gsx$tags': { '$regex': inputname }}
|
||||||
|
]});
|
||||||
|
mugicResults = mugicResults.find({ '$or': [
|
||||||
|
{ 'gsx$name': { '$regex': inputname }},
|
||||||
|
{ 'gsx$tags': { '$regex': inputname }},
|
||||||
|
]});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (negates.length > 0) {
|
||||||
|
const ignoreText = (obj) => {
|
||||||
|
let truth = false;
|
||||||
|
negates.forEach((word) => {
|
||||||
|
truth |= (obj.gsx$name.toLowerCase().indexOf(word.toLowerCase().replace('_', ' ')) > -1);
|
||||||
|
});
|
||||||
|
return !truth;
|
||||||
|
}
|
||||||
|
|
||||||
|
attackResults = attackResults.where(ignoreText);
|
||||||
|
battlegearResults = battlegearResults.where(ignoreText);
|
||||||
|
creatureResults = creatureResults.where(ignoreText);
|
||||||
|
locationResults = locationResults.where(ignoreText);
|
||||||
|
mugicResults = mugicResults.where(ignoreText);
|
||||||
|
}
|
||||||
|
|
||||||
attackResults = attackResults.find({ '$or': [
|
|
||||||
{ 'gsx$name': { '$regex': inputname }},
|
|
||||||
{ 'gsx$tags': { '$regex': inputname }},
|
|
||||||
]});
|
|
||||||
battlegearResults = battlegearResults.find({ '$or': [
|
|
||||||
{ 'gsx$name': { '$regex': inputname }},
|
|
||||||
{ 'gsx$tags': { '$regex': inputname }},
|
|
||||||
]});
|
|
||||||
creatureResults = creatureResults.find({ '$or': [
|
|
||||||
{ 'gsx$name': { '$regex': inputname }},
|
|
||||||
{ 'gsx$tags': { '$regex': inputname }},
|
|
||||||
]});
|
|
||||||
locationResults = locationResults.find({ '$or': [
|
|
||||||
{ 'gsx$name': { '$regex': inputname }},
|
|
||||||
{ 'gsx$tags': { '$regex': inputname }}
|
|
||||||
]});
|
|
||||||
mugicResults = mugicResults.find({ '$or': [
|
|
||||||
{ 'gsx$name': { '$regex': inputname }},
|
|
||||||
{ 'gsx$tags': { '$regex': inputname }},
|
|
||||||
]});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -111,7 +133,7 @@ export default function search_api(input) {
|
||||||
|
|
||||||
attackResults = attackResults.where(ignoreText);
|
attackResults = attackResults.where(ignoreText);
|
||||||
battlegearResults = battlegearResults.where(ignoreText);
|
battlegearResults = battlegearResults.where(ignoreText);
|
||||||
creatureResults = creatureResults.where(ignoreText, true);
|
creatureResults = creatureResults.where(obj => ignoreText(obj, true));
|
||||||
locationResults = locationResults.where(ignoreText);
|
locationResults = locationResults.where(ignoreText);
|
||||||
mugicResults = mugicResults.where(ignoreText);
|
mugicResults = mugicResults.where(ignoreText);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user