mirror of
https://github.com/chaoticbackup/chaoticbackup.github.io.git
synced 2026-04-04 16:14:49 -05:00
#34 sets query in url
This commit is contained in:
parent
54da253d40
commit
0205410dd0
|
|
@ -1,167 +1,137 @@
|
|||
import React from 'react';
|
||||
import API from '../SpreadsheetData';
|
||||
import {observable} from "mobx";
|
||||
import {observer, inject} from 'mobx-react';
|
||||
import loki from 'lokijs';
|
||||
import Collapsible from 'react-collapsible';
|
||||
import API from '../SpreadsheetData';
|
||||
|
||||
@inject((stores, props, context) => props) @observer
|
||||
export default class SearchForm extends React.Component {
|
||||
@observable swamp = "or";
|
||||
export default class SearchCollection extends React.Component {
|
||||
@observable loaded = false;
|
||||
@observable input = {};
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.reset();
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.filter = new loki("filter.db");
|
||||
|
||||
// Binding for keeping scope
|
||||
this.search = this.search.bind(this);
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.reset = this.reset.bind(this);
|
||||
|
||||
this.parseQuery();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.search();
|
||||
// this.search();
|
||||
}
|
||||
|
||||
reset = () => {
|
||||
this.type = {};
|
||||
this.stones = {};
|
||||
this.tribes = {};
|
||||
this.elements = {};
|
||||
this.rarity = {};
|
||||
this.sets = {};
|
||||
this.gender = {};
|
||||
this.mc = {};
|
||||
this.energy = {};
|
||||
this.bp = {};
|
||||
this.base = {};
|
||||
};
|
||||
parseQuery() {
|
||||
this.props.handleContent([{'text': 'Loading...'}]);
|
||||
const queryString = this.props.location.search.toLowerCase();
|
||||
|
||||
let query = {};
|
||||
let pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
|
||||
for (let i = 0; i < pairs.length; i++) {
|
||||
let pair = pairs[i].split('=');
|
||||
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
|
||||
}
|
||||
|
||||
console.log(query);
|
||||
|
||||
if (query.sets) {
|
||||
query.sets.split(',').map(item => {
|
||||
this.input[item.toUpperCase()] = true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateQuery() {
|
||||
let query = {sets:[]};
|
||||
|
||||
Object.keys(this.input).forEach((key) => {
|
||||
if (key in API.sets) query.sets.push(key);
|
||||
});
|
||||
|
||||
let queryString = "";
|
||||
|
||||
// Sets
|
||||
if (query.sets.length > 0) {
|
||||
queryString += "sets=";
|
||||
query.sets.forEach(item => {
|
||||
queryString += item.toLowerCase();
|
||||
});
|
||||
queryString += "&";
|
||||
}
|
||||
|
||||
// encodeURIComponent
|
||||
|
||||
// Strip trailing &
|
||||
queryString = queryString.replace(/\&$/, '');
|
||||
|
||||
this.props.history.push('/collection/?'+(queryString));
|
||||
}
|
||||
|
||||
reset(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.props.history.push('/collection/');
|
||||
Object.keys(this.input).forEach((key) => {
|
||||
(typeof(this.input[key]) === 'boolean' ? this.input[key] = false : this.input[key] = '');
|
||||
});
|
||||
}
|
||||
|
||||
handleChange(event) {
|
||||
const target = event.target;
|
||||
const value = target.type === 'checkbox' ? target.checked : target.value;
|
||||
const name = target.name;
|
||||
this.input[name] = value;
|
||||
|
||||
console.log(this.input);
|
||||
}
|
||||
|
||||
render() {
|
||||
if (API.urls === null ||
|
||||
API.portal === null ||
|
||||
API.cards === null) {
|
||||
return (<span>Loading...</span>);
|
||||
}
|
||||
|
||||
if (this.loaded == false) {
|
||||
API.buildCollection([{'cards': 'attacks'}, {'cards': 'battlegear'}, {'cards': 'creatures'}, {'cards': 'locations'}, {'cards': 'mugic'}])
|
||||
.then(() => {
|
||||
this.loaded = true;
|
||||
this.search();
|
||||
});
|
||||
return (<span>Loading...</span>);
|
||||
}
|
||||
|
||||
let setsInput = [];
|
||||
for (const key in API.sets) {
|
||||
setsInput.push(<label style={{display: 'block'}} key={key}><input type="checkbox" ref={(input) => this.sets[key] = input} />{API.sets[key]}</label>);
|
||||
setsInput.push(<label style={{display: 'block'}} key={key}><input name={key} checked={this.input[key]} type="checkbox" onChange={this.handleChange} />{API.sets[key]}</label>);
|
||||
}
|
||||
|
||||
const card_types = (
|
||||
<div>
|
||||
<label><input type="checkbox" ref={(input) => this.type.Attack = input} />Attack</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.type.Battlegear = input} />Battlegear</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.type.Creature = input} />Creature</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.type.Location = input} />Location</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.type.Mugic = input} />Mugic</label>
|
||||
</div>
|
||||
);
|
||||
|
||||
const card_rarity = (
|
||||
<div>
|
||||
<label><input type="checkbox" ref={(input) => this.rarity["Common"] = input}/>Common</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.rarity["Uncommon"] = input}/>Uncommon</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.rarity["Rare"] = input}/>Rare</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.rarity["Super Rare"] = input}/>Super Rare</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.rarity["Ultra Rare"] = input}/>Ultra Rare</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.rarity["Promo"] = input}/>Promo</label>
|
||||
</div>
|
||||
);
|
||||
|
||||
const card_tribes = (
|
||||
<div>
|
||||
<div>Tribes</div>
|
||||
<input type="checkbox" ref={(input) => this.tribes.danian = input}/><img className="icon16" src={"/src/img/icons/tribes/danian.png"} />
|
||||
<input type="checkbox" ref={(input) => this.tribes.mipedian = input}/><img className="icon16" src={"/src/img/icons/tribes/mipedian.png"} />
|
||||
<input type="checkbox" ref={(input) => this.tribes.overworld = input}/><img className="icon16" src={"/src/img/icons/tribes/overworld.png"} />
|
||||
<input type="checkbox" ref={(input) => this.tribes.underworld = input}/><img className="icon16" src={"/src/img/icons/tribes/underworld.png"} />
|
||||
<input type="checkbox" ref={(input) => this.tribes["m'arrillian"] = input}/><img className="icon16" src={"/src/img/icons/tribes/m'arrillian.png"} />
|
||||
<input type="checkbox" ref={(input) => this.tribes.generic = input}/><img className="icon16" src={"/src/img/icons/tribes/generic.png"} />
|
||||
</div>
|
||||
);
|
||||
|
||||
const card_elements = (
|
||||
<div>
|
||||
<div>Elements</div>
|
||||
<input type="checkbox" ref={(input) => this.elements.fire = input} /><img className="icon16" src={"/src/img/icons/elements/fire.png"} />
|
||||
<input type="checkbox" ref={(input) => this.elements.air = input}/><img className="icon16" src={"/src/img/icons/elements/air.png"} />
|
||||
<input type="checkbox" ref={(input) => this.elements.earth = input}/><img className="icon16" src={"/src/img/icons/elements/earth.png"} />
|
||||
<input type="checkbox" ref={(input) => this.elements.water = input}/><img className="icon16" src={"/src/img/icons/elements/water.png"} />
|
||||
<input type="button" value="or" disabled={this.swamp=="or"} onClick={(e)=>this.swamp="or"}/>
|
||||
<input type="button" value="and" disabled={this.swamp=="and"} onClick={(e)=>this.swamp="and"} />
|
||||
<br />
|
||||
<input type="checkbox" ref={(input) => this.stones.noElements = input}/><span>No Elements</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
const card_disciplines = (
|
||||
<div className="disciplines">
|
||||
<div>Disciplines</div>
|
||||
<input type="text" ref={(input) => this.stones.courage = input} /><img className="icon20" style={{verticalAlign: 'bottom'}} src={"/src/img/icons/disciplines/courage.png"} />
|
||||
<input type="text" ref={(input) => this.stones.power = input} /><img className="icon20" style={{verticalAlign: 'bottom'}} src={"/src/img/icons/disciplines/power.png"} />
|
||||
<input type="text" ref={(input) => this.stones.wisdom = input} /><img className="icon20" style={{verticalAlign: 'bottom'}} src={"/src/img/icons/disciplines/wisdom.png"} />
|
||||
<input type="text" ref={(input) => this.stones.speed = input} /><img className="icon20" style={{verticalAlign: 'bottom'}} src={"/src/img/icons/disciplines/speed.png"} />
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="SearchForm">
|
||||
<form onSubmit={this.search}>
|
||||
<br />
|
||||
<label>Name <input type="text" ref={(input) => this.stones.name = input} /></label>
|
||||
<br />
|
||||
<label>Text <input type="text" ref={(input) => this.stones.text = input} /></label>
|
||||
<br />
|
||||
<div>
|
||||
<label>Subtypes | Initiative<br />
|
||||
<input type="text" ref={(input) => this.stones.subtypes = input} />
|
||||
</label><br />
|
||||
<label><input type="checkbox" ref={(input) => this.stones.past = input}/>Past</label>
|
||||
<label><input type="checkbox" ref={(input) => this.stones.mirage = input}/>Mirage</label>
|
||||
</div>
|
||||
<br />
|
||||
{card_tribes}
|
||||
<br />
|
||||
{card_elements}
|
||||
<br />
|
||||
{card_disciplines}
|
||||
<br />
|
||||
<div>
|
||||
<span>Energy</span><br />
|
||||
<label>Min: <input type="text" style={{width: '30px'}} ref={(input) => this.energy.min = input} /></label>
|
||||
<label>Max: <input type="text" style={{width: '30px'}} ref={(input) => this.energy.max = input} /></label>
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<span>Mugic Counters/Cost
|
||||
<br />Build Points</span><br />
|
||||
<label>Min: <input type="text" style={{width: '30px'}} ref={(input) => this.mc.min = input} /></label>
|
||||
<label>Max: <input type="text" style={{width: '30px'}} ref={(input) => this.mc.max = input} /></label>
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<label><input type="checkbox" ref={(input) => this.stones.unique = input}/>Unique</label>
|
||||
<label><input type="checkbox" ref={(input) => this.stones.loyal = input}/>Loyal</label>
|
||||
<label><input type="checkbox" ref={(input) => this.stones.legendary = input}/>Legendary</label>
|
||||
<br />
|
||||
<label><input type="checkbox" ref={(input) => this.stones.mixed = input}/>Non-Loyal</label>
|
||||
</div>
|
||||
<br />
|
||||
<Collapsible trigger="Types">{card_types}</Collapsible>
|
||||
<Collapsible trigger="Rarity">{card_rarity}</Collapsible>
|
||||
<Collapsible trigger="Sets">{setsInput}</Collapsible>
|
||||
<Collapsible trigger="Gender (fan content)">
|
||||
<label><input type="checkbox" ref={(input) => this.gender.Ambiguous = input}/>Ambiguous</label>
|
||||
<label><input type="checkbox" ref={(input) => this.gender.Female = input}/>Female</label>
|
||||
<label><input type="checkbox" ref={(input) => this.gender.Male = input}/>Male</label>
|
||||
</Collapsible>
|
||||
<br />
|
||||
<input type="submit" value="Search" />
|
||||
<input type="button" value="Reset" disabled onClick={this.reset()} />
|
||||
<input type="button" value="Reset" onClick={this.reset} />
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// TODO advanced filters
|
||||
search = (e) => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.updateQuery();
|
||||
}
|
||||
|
||||
// Sort data descending alphabetically
|
||||
let filter = this.filter.addCollection('filter');
|
||||
var pview = filter.addDynamicView('filter');
|
||||
|
|
@ -174,291 +144,34 @@ export default class SearchForm extends React.Component {
|
|||
let locationResults = API.cards.locations.chain();
|
||||
let mugicResults = API.cards.mugic.chain();
|
||||
|
||||
// Search by name
|
||||
if (this.stones.name.value) {
|
||||
attackResults = attackResults.find({'$or': [
|
||||
{'gsx$name': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
{'gsx$tags': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
]});
|
||||
battlegearResults = battlegearResults.find({'$or': [
|
||||
{'gsx$name': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
{'gsx$tags': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
]});
|
||||
creatureResults = creatureResults.find({'$or': [
|
||||
{'gsx$name': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
{'gsx$tags': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
]});
|
||||
locationResults = locationResults.find({'$or': [
|
||||
{'gsx$name': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
{'gsx$tags': {'$regex': new RegExp(this.stones.name.value, 'i')}}
|
||||
]});
|
||||
mugicResults = mugicResults.find({'$or': [
|
||||
{'gsx$name': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
{'gsx$tags': {'$regex': new RegExp(this.stones.name.value, 'i')}},
|
||||
]});
|
||||
}
|
||||
|
||||
if (this.stones.text.value) {
|
||||
let textList = this.stones.text.value.split(",").filter(Boolean).map((item) => {
|
||||
return ({'$regex': new RegExp(item.trim(), 'i')});
|
||||
});
|
||||
attackResults = attackResults.find({'$or': [
|
||||
{'gsx$tags': {"$or": textList}},
|
||||
{'gsx$ability': {"$or": textList}},
|
||||
{'gsx$flavortext': {"$or": textList}}
|
||||
]});
|
||||
battlegearResults = battlegearResults.find({'$or': [
|
||||
{'gsx$tags': {"$or": textList}},
|
||||
{'gsx$ability': {"$or": textList}},
|
||||
{'gsx$flavortext': {"$or": textList}}
|
||||
]});
|
||||
creatureResults = creatureResults.find({'$or': [
|
||||
{'gsx$tags': {"$or": textList}},
|
||||
{'gsx$ability': {"$or": textList}},
|
||||
{'gsx$flavortext': {"$or": textList}},
|
||||
{'gsx$brainwashedability': {"$or": textList}}
|
||||
]});
|
||||
locationResults = locationResults.find({'$or': [
|
||||
{'gsx$tags': {"$or": textList}},
|
||||
{'gsx$ability': {"$or": textList}},
|
||||
{'gsx$flavortext': {"$or": textList}}
|
||||
]});
|
||||
mugicResults = mugicResults.find({'$or': [
|
||||
{'gsx$tags': {"$or": textList}},
|
||||
{'gsx$ability': {"$or": textList}},
|
||||
{'gsx$flavortext': {"$or": textList}}
|
||||
]});
|
||||
}
|
||||
|
||||
// Search by tribe
|
||||
let tribesList = [];
|
||||
for (const tribe in this.tribes) {
|
||||
if (this.tribes[tribe].checked) {
|
||||
tribesList.push({'$regex': new RegExp(tribe, 'i')});
|
||||
}
|
||||
}
|
||||
if (tribesList.length > 0) {
|
||||
creatureResults = creatureResults.find({'gsx$tribe': {'$or': tribesList} });
|
||||
mugicResults = mugicResults.find({'gsx$tribe': {'$or': tribesList} });
|
||||
attackResults = attackResults.limit(0);
|
||||
battlegearResults = battlegearResults.limit(0);
|
||||
locationResults = locationResults.limit(0);
|
||||
}
|
||||
|
||||
// no elements
|
||||
if (this.stones.noElements.checked) {
|
||||
creatureResults = creatureResults.where((obj) => {return (obj.gsx$elements == '');});
|
||||
attackResults = attackResults.where(
|
||||
(obj) => {return (obj.gsx$fire == ('') );}
|
||||
).where(
|
||||
(obj) => {return (obj.gsx$air == ('') );}
|
||||
).where(
|
||||
(obj) => {return (obj.gsx$earth == ('') );}
|
||||
).where(
|
||||
(obj) => {return (obj.gsx$water == ('') );}
|
||||
);
|
||||
battlegearResults = battlegearResults.limit(0);
|
||||
locationResults = locationResults.limit(0);
|
||||
mugicResults = mugicResults.limit(0);
|
||||
}
|
||||
// Search by elements
|
||||
else {
|
||||
let elementsList = [];
|
||||
let elementsList2 = [];
|
||||
for (const element in this.elements) {
|
||||
if (this.elements[element].checked) {
|
||||
elementsList.push({'$regex': new RegExp(element, 'i')});
|
||||
elementsList2.push({['gsx$'+element]: {'$gte': 0}})
|
||||
}
|
||||
}
|
||||
if (elementsList.length > 0) {
|
||||
if (this.swamp == "or") {
|
||||
creatureResults = creatureResults.find({'gsx$elements': {'$or': elementsList} });
|
||||
attackResults = attackResults.find({'$or': elementsList2});
|
||||
}
|
||||
if (this.swamp == "and") {
|
||||
creatureResults = creatureResults.find({'gsx$elements': {'$and': elementsList} });
|
||||
attackResults = attackResults.find({'$and': elementsList2});
|
||||
}
|
||||
battlegearResults = battlegearResults.limit(0);
|
||||
locationResults = locationResults.limit(0);
|
||||
mugicResults = mugicResults.limit(0);
|
||||
}
|
||||
}
|
||||
|
||||
let rarityList = [];
|
||||
for (const key in this.rarity) {
|
||||
if (this.rarity[key].checked) {
|
||||
rarityList.push({'$eq': key});
|
||||
}
|
||||
}
|
||||
if (rarityList.length > 0) {
|
||||
attackResults = attackResults.find({'gsx$rarity': {'$or': rarityList} });
|
||||
battlegearResults = battlegearResults.find({'gsx$rarity': {'$or': rarityList} });
|
||||
creatureResults = creatureResults.find({'gsx$rarity': {'$or': rarityList} });
|
||||
locationResults = locationResults.find({'gsx$rarity': {'$or': rarityList} });
|
||||
mugicResults = mugicResults.find({'gsx$rarity': {'$or': rarityList} });
|
||||
}
|
||||
|
||||
let setsList = [];
|
||||
for (const key in this.sets) {
|
||||
if (this.sets[key].checked) {
|
||||
setsList.push({'$eq': key});
|
||||
}
|
||||
}
|
||||
if (setsList.length > 0) {
|
||||
attackResults = attackResults.find({'gsx$set': {'$or': setsList} });
|
||||
battlegearResults = battlegearResults.find({'gsx$set': {'$or': setsList} });
|
||||
creatureResults = creatureResults.find({'gsx$set': {'$or': setsList} });
|
||||
locationResults = locationResults.find({'gsx$set': {'$or': setsList} });
|
||||
mugicResults = mugicResults.find({'gsx$set': {'$or': setsList} });
|
||||
}
|
||||
|
||||
if (this.stones.subtypes.value) {
|
||||
let subtypesList = this.stones.subtypes.value.split(",").filter(Boolean).map((item) => {
|
||||
return ({'$regex': new RegExp(item.trim(), 'i')});
|
||||
});
|
||||
|
||||
creatureResults = creatureResults.find({'gsx$types': {'$or': subtypesList} });
|
||||
locationResults = locationResults.find({'gsx$initiative': {'$or': subtypesList}});
|
||||
attackResults = attackResults.limit(0);
|
||||
battlegearResults = battlegearResults.limit(0);
|
||||
mugicResults = mugicResults.limit(0);
|
||||
}
|
||||
|
||||
if (this.mc.min.value !== "" && this.mc.min.value >= 0) {
|
||||
attackResults = attackResults.find({'gsx$bp': {'$gte': this.mc.min.value}});
|
||||
creatureResults = creatureResults.find({'gsx$mugicability': {'$gte': this.mc.min.value}});
|
||||
mugicResults = mugicResults.find({'gsx$cost': {'$gte': this.mc.min.value}});
|
||||
}
|
||||
if (this.mc.max.value !== "" && this.mc.max.value >= 0 && this.mc.max.value >= this.mc.min.value) {
|
||||
attackResults = attackResults.find({'gsx$bp': {'$lte': this.mc.max.value}});
|
||||
creatureResults = creatureResults.find({'gsx$mugicability': {'$lte': this.mc.max.value}});
|
||||
mugicResults = mugicResults.find({'gsx$cost': {'$lte': this.mc.max.value}});
|
||||
}
|
||||
|
||||
if (this.mc.max.value !== "" || this.mc.min.value !== "") {
|
||||
battlegearResults = battlegearResults.limit(0);
|
||||
locationResults = locationResults.limit(0);
|
||||
}
|
||||
|
||||
if (this.energy.min.value > 0) {
|
||||
creatureResults = creatureResults.find({'gsx$energy': {'$gte': this.energy.min.value}});
|
||||
}
|
||||
if (this.energy.max.value > 0 && this.energy.max.value >= this.energy.min.value) {
|
||||
creatureResults = creatureResults.find({'gsx$energy': {'$lte': this.energy.max.value}});
|
||||
}
|
||||
|
||||
if (this.stones.courage.value > 0) {
|
||||
creatureResults = creatureResults.find({'gsx$courage': {'$gte': this.stones.courage.value}});
|
||||
}
|
||||
if (this.stones.power.value > 0) {
|
||||
creatureResults = creatureResults.find({'gsx$power': {'$gte': this.stones.power.value}});
|
||||
}
|
||||
if (this.stones.wisdom.value > 0) {
|
||||
creatureResults = creatureResults.find({'gsx$wisdom': {'$gte': this.stones.wisdom.value}});
|
||||
}
|
||||
if (this.stones.speed.value > 0) {
|
||||
creatureResults = creatureResults.find({'gsx$speed': {'$gte': this.stones.speed.value}});
|
||||
}
|
||||
|
||||
if (this.energy.min.value > 0 || this.energy.max.value > 0 || this.stones.courage.value !== "" || this.stones.power.value !== "" || this.stones.wisdom.value !== "" || this.stones.speed.value !== "") {
|
||||
attackResults = attackResults.limit(0);
|
||||
battlegearResults = battlegearResults.limit(0);
|
||||
locationResults = locationResults.limit(0);
|
||||
mugicResults = mugicResults.limit(0);
|
||||
}
|
||||
|
||||
if (this.stones.unique.checked) {
|
||||
attackResults = attackResults.find({'gsx$unique': {'$gt': 0}});
|
||||
battlegearResults = battlegearResults.find({'gsx$unique': {'$gt': 0}});
|
||||
creatureResults = creatureResults.find({'gsx$unique': {'$gt': 0}});
|
||||
locationResults = locationResults.find({'gsx$unique': {'$gt': 0}});
|
||||
mugicResults = mugicResults.find({'gsx$unique': {'$gt': 0}});
|
||||
}
|
||||
|
||||
if (this.stones.loyal.checked) {
|
||||
attackResults = attackResults.limit(0);
|
||||
battlegearResults = battlegearResults.find({'gsx$loyal': {'$gt': 0}});
|
||||
creatureResults = creatureResults.find({'gsx$loyal': {'$gt': 0}});
|
||||
mugicResults = mugicResults.limit(0);
|
||||
locationResults = locationResults.limit(0);
|
||||
}
|
||||
|
||||
if (this.stones.mixed.checked) {
|
||||
attackResults = attackResults.limit(0);
|
||||
creatureResults = creatureResults.find({'gsx$loyal': {'$lte': 0}});
|
||||
battlegearResults = battlegearResults.find({'gsx$loyal': {'$lte': 0}});
|
||||
mugicResults = mugicResults.limit(0);
|
||||
locationResults = locationResults.limit(0);
|
||||
}
|
||||
|
||||
if (this.stones.legendary.checked) {
|
||||
attackResults = attackResults.find({'gsx$legendary': {'$gt': 0}});
|
||||
battlegearResults = battlegearResults.find({'gsx$legendary': {'$gt': 0}});
|
||||
creatureResults = creatureResults.find({'gsx$legendary': {'$gt': 0}});
|
||||
locationResults = locationResults.find({'gsx$legendary': {'$gt': 0}});
|
||||
mugicResults = mugicResults.find({'gsx$legendary': {'$gt': 0}});
|
||||
}
|
||||
|
||||
if (this.stones.past.checked) {
|
||||
attackResults = attackResults.find({'gsx$past': {'$gt': 0}});
|
||||
battlegearResults = battlegearResults.find({'gsx$past': {'$gt': 0}});
|
||||
creatureResults = creatureResults.find({'gsx$types': {'$regex': new RegExp("past", 'i')}});
|
||||
locationResults = locationResults.find({'gsx$past': {'$gt': 0}});
|
||||
mugicResults = mugicResults.find({'gsx$past': {'$gt': 0}});
|
||||
}
|
||||
|
||||
if (this.stones.mirage.checked) {
|
||||
locationResults = locationResults.find({'gsx$mirage': {'$gt': 0}});
|
||||
attackResults = attackResults.limit(0);
|
||||
battlegearResults = battlegearResults.limit(0);
|
||||
creatureResults = creatureResults.limit(0);
|
||||
mugicResults = mugicResults.limit(0);
|
||||
}
|
||||
|
||||
let genderList = [];
|
||||
for (const key in this.gender) {
|
||||
if (this.gender[key].checked) {
|
||||
genderList.push({'$regex': new RegExp(key, 'i')})
|
||||
}
|
||||
}
|
||||
if (genderList.length > 0) {
|
||||
creatureResults = creatureResults.find({'gsx$gender': {'$or': genderList} });
|
||||
attackResults = attackResults.limit(0);
|
||||
battlegearResults = battlegearResults.limit(0);
|
||||
locationResults = locationResults.limit(0);
|
||||
mugicResults = mugicResults.limit(0);
|
||||
}
|
||||
|
||||
// Merge data
|
||||
let types = !(this.type.Attack.checked | this.type.Battlegear.checked | this.type.Creature.checked | this.type.Location.checked | this.type.Mugic.checked);
|
||||
// let types = !(this.type.Attack.checked | this.type.Battlegear.checked | this.type.Creature.checked | this.type.Location.checked | this.type.Mugic.checked);
|
||||
|
||||
if (types || this.type.Attack.checked) {
|
||||
let temp = attackResults.data();
|
||||
temp.forEach(function(v){ delete v.$loki });
|
||||
filter.insert(temp);
|
||||
}
|
||||
if (types || this.type.Battlegear.checked) {
|
||||
let temp = battlegearResults.data();
|
||||
temp.forEach(function(v){ delete v.$loki });
|
||||
filter.insert(temp);
|
||||
}
|
||||
if (types || this.type.Creature.checked) {
|
||||
let temp = creatureResults.data()
|
||||
temp.forEach(function(v){ delete v.$loki });
|
||||
filter.insert(temp);
|
||||
}
|
||||
if (types || this.type.Location.checked) {
|
||||
let temp = locationResults.data()
|
||||
temp.forEach(function(v){ delete v.$loki });
|
||||
filter.insert(temp);
|
||||
}
|
||||
if (types || this.type.Mugic.checked) {
|
||||
let temp = mugicResults.data()
|
||||
temp.forEach(function(v){ delete v.$loki });
|
||||
filter.insert(temp);
|
||||
}
|
||||
// if (types || this.type.Attack.checked) {
|
||||
// let temp = attackResults.data();
|
||||
// temp.forEach(function(v){ delete v.$loki });
|
||||
// filter.insert(temp);
|
||||
// }
|
||||
// if (types || this.type.Battlegear.checked) {
|
||||
// let temp = battlegearResults.data();
|
||||
// temp.forEach(function(v){ delete v.$loki });
|
||||
// filter.insert(temp);
|
||||
// }
|
||||
// if (types || this.type.Creature.checked) {
|
||||
// let temp = creatureResults.data()
|
||||
// temp.forEach(function(v){ delete v.$loki });
|
||||
// filter.insert(temp);
|
||||
// }
|
||||
// if (types || this.type.Location.checked) {
|
||||
// let temp = locationResults.data()
|
||||
// temp.forEach(function(v){ delete v.$loki });
|
||||
// filter.insert(temp);
|
||||
// }
|
||||
// if (types || this.type.Mugic.checked) {
|
||||
// let temp = mugicResults.data()
|
||||
// temp.forEach(function(v){ delete v.$loki });
|
||||
// filter.insert(temp);
|
||||
// }
|
||||
|
||||
let results = pview.data();
|
||||
this.filter.removeCollection('filter');
|
||||
|
|
@ -466,4 +179,5 @@ export default class SearchForm extends React.Component {
|
|||
if (results.length > 0) this.props.handleContent(results);
|
||||
else this.props.handleContent([{'text': 'No Results Found'}]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,31 +25,18 @@ export default class Home extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
|
||||
if (API.urls === null ||
|
||||
API.portal === null ||
|
||||
API.cards === null) {
|
||||
return (<span>Loading...</span>);
|
||||
}
|
||||
|
||||
if (this.loaded == false) {
|
||||
API.buildCollection([{'cards': 'attacks'}, , {'cards': 'battlegear'}, {'cards': 'creatures'}, {'cards': 'locations'}, {'cards': 'mugic'}])
|
||||
.then(() => {
|
||||
this.loaded = true;
|
||||
});
|
||||
return (<span>Loading...</span>);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="collection">
|
||||
<link rel="stylesheet" href="/src/css/collection.css" />
|
||||
<div className="left">
|
||||
<ImagePreview url={API.base_image + this.card_img} ref={n => {if (n) this.changeImage = n.getInstance().changeImage}} />
|
||||
<SearchForm handleContent={this.handleContent.bind(this)} />
|
||||
<SearchForm handleContent={this.handleContent.bind(this)} {...this.props} />
|
||||
</div>
|
||||
<div className="right">
|
||||
{this.navigation()}<br />
|
||||
{this.navigation()}
|
||||
<br />
|
||||
<CardList cards={this.content.slice(this.n * (this.p-1), this.n * this.p)} setImage={this.setImage.bind(this)}/>
|
||||
<br />
|
||||
{this.navigation()}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ export default class PackSimulator extends React.Component {
|
|||
const target = event.target;
|
||||
const value = target.type === 'checkbox' ? target.checked : target.value;
|
||||
const name = target.name;
|
||||
|
||||
this[name] = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class DBSearch extends React.Component {
|
|||
}
|
||||
|
||||
if (this.loaded == false) {
|
||||
API.buildCollection([{'portal': 'attacks'}, , {'portal': 'battlegear'}, {'portal': 'creatures'}, {'portal': 'locations'}, {'portal': 'mugic'}])
|
||||
API.buildCollection([{'portal': 'attacks'}, {'portal': 'battlegear'}, {'portal': 'creatures'}, {'portal': 'locations'}, {'portal': 'mugic'}])
|
||||
.then(() => {
|
||||
this.loaded = true;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user