negation query

This commit is contained in:
Daniel 2020-06-22 15:06:19 -04:00
parent dae0783390
commit d1f43b9c4c
11 changed files with 1090 additions and 988 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
@media only screen and (min-width:975px){.pack{max-width:70%}}.packsim input[type=number]::-webkit-inner-spin-button,.packsim input[type=number]::-webkit-outer-spin-button{opacity:1}.pack{height:100%;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:center;margin:auto}.pack .card{width:150px;height:210px;background-size:cover;box-sizing:content-box;margin:5px;-webkit-transition:-webkit-transform 1s,opacity 1s,background 1s,width 1s,height 1s,font-size 1s,top 1s,left 1s;-webkit-border-radius:5px;-o-transition-property:width,height,-o-transform,background,font-size,opacity,top,left;-o-transition-duration:1s,1s,1s,1s,1s,1s,1s,1s;-moz-transition-property:width,height,-o-transform,background,font-size,opacity,top,left;-moz-transition-duration:1s,1s,1s,1s,1s,1s,1s,1s;transition-property:width,height,transform,background,font-size,opacity,top,left;transition-duration:1s,1s,1s,1s,1s,1s,1s,1s}.pack .card:hover{width:250px;height:350px}.pack .stats{height:100%;width:100%;text-align:left}.pack .stats span{position:relative;color:#000;display:block;left:10px;font-size:12px}.pack .stats span:first-of-type{top:130px}.pack .stats span:nth-of-type(2){top:128px}.pack .stats span:nth-of-type(3){top:126px}.pack .stats span:nth-of-type(4){top:124px}.pack .stats span:nth-of-type(5){text-align:right;top:125px;left:-11px;font-size:14px}.pack .card:hover .stats span{left:20px;font-size:14px;font-weight:700}.pack .card:hover .stats span:first-of-type{top:220px}.pack .card:hover .stats span:nth-of-type(2){top:229px}.pack .card:hover .stats span:nth-of-type(3){top:237px}.pack .card:hover .stats span:nth-of-type(4){top:245px}.pack .card:hover .stats span:nth-of-type(5){text-align:right;top:258px;left:-21px;font-size:20px}
@media only screen and (min-width:975px){.pack{max-width:90%}}.packsim input[type=number]::-webkit-inner-spin-button,.packsim input[type=number]::-webkit-outer-spin-button{opacity:1}.pack{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:center;margin:auto}.pack .card{width:150px;height:210px;background-size:cover;box-sizing:content-box;margin:5px;-webkit-transition:-webkit-transform 1s,opacity 1s,background 1s,width 1s,height 1s,font-size 1s,top 1s,left 1s;-webkit-border-radius:5px;-o-transition-property:width,height,-o-transform,background,font-size,opacity,top,left;-o-transition-duration:1s,1s,1s,1s,1s,1s,1s,1s;-moz-transition-property:width,height,-o-transform,background,font-size,opacity,top,left;-moz-transition-duration:1s,1s,1s,1s,1s,1s,1s,1s;transition-property:width,height,transform,background,font-size,opacity,top,left;transition-duration:1s,1s,1s,1s,1s,1s,1s,1s}.pack .card:hover{width:250px;height:350px}.pack .stats{height:100%;width:100%;text-align:left}.pack .stats span{position:relative;color:#000;display:block;left:10px;font-size:12px}.pack .stats span:first-of-type{top:130px}.pack .stats span:nth-of-type(2){top:128px}.pack .stats span:nth-of-type(3){top:126px}.pack .stats span:nth-of-type(4){top:124px}.pack .stats span:nth-of-type(5){text-align:right;top:125px;left:-11px;font-size:14px}.pack .card:hover .stats span{left:20px;font-size:14px;font-weight:700}.pack .card:hover .stats span:first-of-type{top:220px}.pack .card:hover .stats span:nth-of-type(2){top:229px}.pack .card:hover .stats span:nth-of-type(3){top:237px}.pack .card:hover .stats span:nth-of-type(4){top:245px}.pack .card:hover .stats span:nth-of-type(5){text-align:right;top:258px;left:-21px;font-size:20px}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{1069:function(e,t,n){},1072:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return g}));var a=n(169),r=n.n(a),l=n(82),o=n.n(l),c=n(63),i=n.n(c),s=n(167),u=n.n(s),f=n(168),m=n.n(f),d=n(130),h=n.n(d),p=n(0),b=n.n(p),E=n(83),v=n(56);n(1069),n(3);function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}var k=function(){return b.a.createElement("a",{href:"https://github.com/chaoticbackup",className:"name",rel:"noreferrer noopener",target:"_blank"},"Chaotic Backup Project")},w=function(e){var t=e.block,n=e.text,a=e.sets;return b.a.createElement("div",{className:"lore"},b.a.createElement("div",{className:"block"},t),n.map((function(e,t){return b.a.createElement("div",{key:t,dangerouslySetInnerHTML:{__html:e}})})),a.map((function(e,t){if(e.text&&e.text.length>0)return b.a.createElement("div",{className:"set",key:t},b.a.createElement("div",{className:"title"},e.title),e.text.map((function(e,t){return b.a.createElement("div",{key:t},e)})))})))},g=function(e){u()(a,e);var t,n=(t=a,function(){var e,n=h()(t);if(y()){var a=h()(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return m()(this,e)});function a(){var e;o()(this,a);for(var t=arguments.length,r=new Array(t),l=0;l<t;l++)r[l]=arguments[l];return(e=n.call.apply(n,[this].concat(r))).state={lore:[]},e}return i()(a,[{key:"componentDidMount",value:function(){var e=this;fetch("/src/json/starter_lore.json").then((function(e){return e.json()})).then((function(t){e.setState({lore:t})})).catch((function(){e.setState({lore:[{block:"Unable to load lore...",text:[]}]})}))}},{key:"render",value:function(){return b.a.createElement("div",null,b.a.createElement("br",null),b.a.createElement("div",{className:"with-love"},b.a.createElement("div",null,"Welcome to the ",b.a.createElement(k,null),"."),b.a.createElement("span",null,"Built by fans for fans."),b.a.createElement("br",null),b.a.createElement("br",null),b.a.createElement("div",null,"Made with ",b.a.createElement("span",{className:"heart"},"♥")," by",b.a.createElement("br",null),"Danude Sandstorm (Project Lead)",b.a.createElement("br",null),"Chiodosin1 (Database Contributions)",b.a.createElement("br",null),"Afjak and Blitser (Art and Knowledge)"),b.a.createElement("div",null,"Do you like the site? You can donate to support it!"),b.a.createElement("div",{className:"donate"},b.a.createElement(v.e,null)),b.a.createElement("div",{className:"lore"},"We were unsatisfied with the options on how to search for cards. I took the design of the old Chaotic website and added my own modernizations. With an extensive lists of search options in the ",b.a.createElement(E.b,{to:"/collection"},"collection"),", you'll find deck building mores streamlined than ever before. Chaotic is full of rich lore, but unfortunately the best database of official lore disapeared when the ",b.a.createElement(E.b,{to:"/portal"},"Portal to Perim")," disapeared along with the site. You can again explore the official lore and information of Creatures!"),b.a.createElement("br",null),this.state.lore.length>0?this.state.lore.map((function(e,t){return b.a.createElement(w,r()({key:t},e))})):"Loading lore entries..."))}}]),a}(b.a.Component)}}]);
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{1068:function(e,t,n){},1071:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return g}));var a=n(169),r=n.n(a),o=n(82),l=n.n(o),c=n(63),i=n.n(c),s=n(167),u=n.n(s),f=n(168),m=n.n(f),d=n(130),h=n.n(d),p=n(0),b=n.n(p),v=n(83),E=n(57);n(1068),n(3);function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,a=h()(e);if(t){var r=h()(this).constructor;n=Reflect.construct(a,arguments,r)}else n=a.apply(this,arguments);return m()(this,n)}}var k=function(){return b.a.createElement("a",{href:"https://github.com/chaoticbackup",className:"name",rel:"noreferrer noopener",target:"_blank"},"Chaotic Backup Project")},w=function(e){var t=e.block,n=e.text,a=e.sets;return b.a.createElement("div",{className:"lore"},b.a.createElement("div",{className:"block"},t),n.map((function(e,t){return b.a.createElement("div",{key:t,dangerouslySetInnerHTML:{__html:e}})})),a.map((function(e,t){if(e.text&&e.text.length>0)return b.a.createElement("div",{className:"set",key:t},b.a.createElement("div",{className:"title"},e.title),e.text.map((function(e,t){return b.a.createElement("div",{key:t},e)})))})))},g=function(e){u()(n,e);var t=y(n);function n(){var e;l()(this,n);for(var a=arguments.length,r=new Array(a),o=0;o<a;o++)r[o]=arguments[o];return(e=t.call.apply(t,[this].concat(r))).state={lore:[]},e}return i()(n,[{key:"componentDidMount",value:function(){var e=this;fetch("/src/json/starter_lore.json").then((function(e){return e.json()})).then((function(t){e.setState({lore:t})})).catch((function(){e.setState({lore:[{block:"Unable to load lore...",text:[]}]})}))}},{key:"render",value:function(){return b.a.createElement("div",null,b.a.createElement("br",null),b.a.createElement("div",{className:"with-love"},b.a.createElement("div",null,"Welcome to the ",b.a.createElement(k,null),"."),b.a.createElement("span",null,"Built by fans for fans."),b.a.createElement("br",null),b.a.createElement("br",null),b.a.createElement("div",null,"Made with ",b.a.createElement("span",{className:"heart"},"♥")," by",b.a.createElement("br",null),"Danude Sandstorm (Project Lead)",b.a.createElement("br",null),"Chiodosin1 (Database Contributions)",b.a.createElement("br",null),"Afjak and Blitser (Art and Knowledge)"),b.a.createElement("div",null,"Do you like the site? You can donate to support it!"),b.a.createElement("div",{className:"donate"},b.a.createElement(E.e,null)),b.a.createElement("div",{className:"lore"},"We were unsatisfied with the options on how to search for cards. I took the design of the old Chaotic website and added my own modernizations. With an extensive lists of search options in the ",b.a.createElement(v.b,{to:"/collection"},"collection"),", you'll find deck building mores streamlined than ever before. Chaotic is full of rich lore, but unfortunately the best database of official lore disapeared when the ",b.a.createElement(v.b,{to:"/portal"},"Portal to Perim")," disapeared along with the site. You can again explore the official lore and information of Creatures!"),b.a.createElement("br",null),this.state.lore.length>0?this.state.lore.map((function(e,t){return b.a.createElement(w,r()({key:t},e))})):"Loading lore entries..."))}}]),n}(b.a.Component)}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1945
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,9 @@
"description": "Chaotic Backup",
"scripts": {
"start": "webpack-dev-server -d --inline",
"build": "npm run check-types && webpack -p",
"check-types": "tsc",
"lint": "tsc --noEmit && eslint '*/**/*.{js,ts,tsx}'",
"lint:fix": "tsc --noEmit && eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"build": "webpack -p",
"lint": "tsc --noEmit; eslint '*/**/*.{js,ts,tsx}'",
"lint:fix": "tsc --noEmit; eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register src/**/*.spec.ts"
},
"repository": {
@ -18,7 +17,7 @@
"license": "MIT",
"dependencies": {
"@loadable/component": "^5.12.0",
"@material-ui/core": "^4.10.1",
"@material-ui/core": "^4.10.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/styles": "^4.10.0",
"lokijs": "^1.5.8",
@ -35,41 +34,41 @@
"react-process-string": "^1.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"tone": "^14.7.7",
"tone": "^14.7.11",
"universal-cookie": "^4.0.3",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/node": "^7.10.1",
"@babel/cli": "^7.10.3",
"@babel/core": "^7.10.3",
"@babel/node": "^7.10.3",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-proposal-decorators": "^7.10.1",
"@babel/plugin-proposal-decorators": "^7.10.3",
"@babel/plugin-proposal-dynamic-import": "^7.10.1",
"@babel/plugin-proposal-object-rest-spread": "^7.10.1",
"@babel/plugin-proposal-object-rest-spread": "^7.10.3",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-computed-properties": "^7.10.1",
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/plugin-transform-computed-properties": "^7.10.3",
"@babel/plugin-transform-runtime": "^7.10.3",
"@babel/polyfill": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@babel/preset-env": "^7.10.3",
"@babel/preset-flow": "^7.10.1",
"@babel/preset-react": "^7.10.1",
"@babel/preset-typescript": "^7.10.1",
"@babel/register": "^7.10.1",
"@babel/runtime": "^7.10.2",
"@babel/register": "^7.10.3",
"@babel/runtime": "^7.10.3",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/react": "^16.9.35",
"@types/react": "^16.9.38",
"@types/react-dom": "^16.9.8",
"@types/react-router-dom": "^5.1.5",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"css-loader": "^3.5.3",
"css-loader": "^3.6.0",
"eslint": "^6.8.0",
"eslint-plugin-flowtype": "^4.7.0",
"eslint-plugin-import": "^2.21.1",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^3.0.0",
"ignore-styles": "^5.0.1",
@ -85,7 +84,7 @@
"ts-node": "^8.10.2",
"typescript": "^3.9.5",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
},
"browserslist": {

View File

@ -1,7 +1,7 @@
import React from 'react';
import API from '../SpreadsheetData';
import {observable, action} from "mobx";
import {observer, inject} from 'mobx-react';
import { observable, action } from "mobx";
import { observer, inject } from 'mobx-react';
import CardList from './List';
import SearchForm from './search/index.js';
import './collection.scss'

View File

@ -2,11 +2,13 @@ import loki from 'lokijs';
import API from '../../SpreadsheetData';
function cleanInputRegex(input) {
input = input
.replace(/\\/g, '')
.replace(/\(|\)/g, (match) => {return ("\\"+match)})
.replace(/\|\/g, "'");
return new RegExp(input.trim(), 'i');
input = input
.replace(/\\/g, '')
.replace(/\|\/g, "'")
.replace(/\(|\)/g, (match) => ("\\"+match));
// .replace(/~(\w+)/, (match) => (`\(?!${match}\)`));
return new RegExp(input.trim(), 'i');
}
export default function search_api(input) {
@ -69,32 +71,50 @@ export default function search_api(input) {
// Card Text
if (input.text.length > 0) {
// split text by comma
let textList = input.text.split(",").filter(Boolean).map((item) => {
return ({ '$regex': cleanInputRegex(item) });
});
// clean text
let inputtext = cleanInputRegex(input.text);
const negates = [];
let inputtext = input.text.replace(/(?:~)(\w+)/g, (_, p1) => { negates.push(p1); return ""; });
let parm = (() => {
let list = [
{ 'gsx$tags': { "$or": textList }},
{ 'gsx$ability': { '$regex': inputtext }}
]
if (input.flavor) {
list.push({ 'gsx$flavortext': { "$or": textList }});
list.push({ 'gsx$artist': { "$or": textList }});
if (inputtext.length > 0) {
inputtext = cleanInputRegex(inputtext);
let parm = (() => {
let list = [
{ 'gsx$tags': { "$or": inputtext }},
{ 'gsx$ability': { '$regex': inputtext }}
]
if (input.flavor) {
list.push({ 'gsx$flavortext': { "$or": inputtext }});
list.push({ 'gsx$artist': { "$or": inputtext }});
}
return list;
})();
attackResults = attackResults.find({ '$or': parm })
battlegearResults = battlegearResults.find({ '$or': parm });
creatureResults = creatureResults.find({ '$or':
(parm.concat([{ 'gsx$brainwashed': { '$regex': inputtext }}]))
});
locationResults = locationResults.find({ '$or': parm });
mugicResults = mugicResults.find({ '$or': parm });
}
if (negates.length > 0) {
const ignoreText = (obj, creature=false) => {
let truth = false;
negates.forEach((word) => {
truth |= (obj.gsx$ability.toLowerCase().indexOf(word.toLowerCase()) > -1);
if (creature) truth |= (obj.gsx$flavortext.toLowerCase().indexOf(word.toLowerCase()) > -1);
})
return !truth;
}
return list;
})();
attackResults = attackResults.find({ '$or': parm });
battlegearResults = battlegearResults.find({ '$or': parm });
creatureResults = creatureResults.find({ '$or':
(parm.concat([{ 'gsx$brainwashed': { '$regex': inputtext }}]))
});
locationResults = locationResults.find({ '$or': parm });
mugicResults = mugicResults.find({ '$or': parm });
attackResults = attackResults.where(ignoreText);
battlegearResults = battlegearResults.where(ignoreText);
creatureResults = creatureResults.where(ignoreText, true);
locationResults = locationResults.where(ignoreText);
mugicResults = mugicResults.where(ignoreText);
}
}
// Subtypes / Initiative