This commit is contained in:
Daniel 2017-11-30 12:35:31 -05:00
parent 304bd82428
commit b79aecaa29
9 changed files with 207 additions and 134 deletions

File diff suppressed because one or more lines are too long

View File

@ -48,7 +48,7 @@ function App({ children, routes }) {
<div className="full-width clear-line" style={{marginBottom: "5px"}}>
</div>
</div>
<div className="center-column">
<div className="full-column">
<div className="pods-wrap pad5px-btm">
<div className="clear-line full-width">
<div className="adPod-top-wrap">

View File

@ -20,9 +20,9 @@ export default class Creature extends React.Component {
}
return(
<div style={{textAlign: 'left', display: 'flex'}}>
<div style={{textAlign: 'left', display: 'flex'}} onClick={() => this.props.setImage(creature.gsx$image)}>
<img className="thumb" style={{float: 'left', width: '100px', height: '98px'}} src={API.base_image + (creature.gsx$thumb||API.thumb_missing)}></img>
<div style={{verticalAlign: 'text-top', float: 'left', width: "50%"}}>
<div style={{verticalAlign: 'text-top', float: 'left', width: 'calc(100% - 50px)'}}>
<img height="20" className="icon" src={"/src/img/icons/tribes/"+creature.gsx$tribe.toLowerCase()+".png"}></img>
<span>{creature.gsx$name}</span><br />
<span>{API.sets[creature.gsx$set]} | {creature.gsx$rarity}</span><br />
@ -30,7 +30,7 @@ export default class Creature extends React.Component {
<span>{elements}</span><br />
<span>{mugic}</span><br />
</div>
<div style={{verticalAlign: 'text-top', float: 'left'}}>
<div style={{verticalAlign: 'text-top', float: 'left', width: '50px', textAlign: 'right'}}>
<span>{creature.gsx$courage}&nbsp;<img height="16" className="icon" src={"/src/img/icons/disciplines/courage.png"}></img></span><br />
<span>{creature.gsx$power}&nbsp;<img height="16" className="icon" src={"/src/img/icons/disciplines/power.png"}></img></span><br />
<span>{creature.gsx$wisdom}&nbsp;<img height="16" className="icon" src={"/src/img/icons/disciplines/wisdom.png"}></img></span><br />

View File

@ -3,11 +3,7 @@ import API from '../SpreadsheetData';
import s from '../../styles/app.style';
import {observable} from "mobx";
import {observer, inject} from 'mobx-react';
import Attack from './Attack';
import Battlegear from './Battlegear';
import Creature from './Creature';
import Location from './Location';
import Mugic from './Mugic';
import CardList from './List';
import SearchForm from './Search';
@inject((stores, props, context) => props) @observer
@ -15,17 +11,24 @@ export default class CollectionHome extends React.Component {
@observable n = 10;
@observable p = 1;
@observable content = [];
@observable card_img = API.card_back;
handleContent(content) {
this.content = content;
this.p = 1;
}
setImage(img) {
this.card_img = (img || API.card_back);
}
render() {
if (this.props.children) {
return (<div>{this.props.children}</div>);
}
let loading = false;
const store = API;
if (store.urls === null ||
store.portal === null ||
@ -59,54 +62,34 @@ export default class CollectionHome extends React.Component {
return (<span>Loading...</span>);
}
if (this.content.length == 0) {
// Only use cards with thumb nails for now
this.content = store.cards.creatures.chain().where((obj) => {return (!obj.gsx$thumb == '');}).simplesort('gsx$name').data();
if (loading === true) {
return (<span>Loading...</span>);
}
return (
<div>
<div className="collection">
<link rel="stylesheet" href="/src/css/collection.css" />
<p>
This page is under construction. In the meantime, you can check out&nbsp;
<a style={{textDecoration: "underline"}} href="http://www.tradecardsonline.com/im/editCollection/collection_type/1">Trade Cards Online</a>
.
</p>
<hr />
<SearchForm handleContent={this.handleContent.bind(this)} />
<hr />
{this.navigation()}<br />
{this.output()}
{this.navigation()}<br />
<div className="collection_left">
<div className="card_img">
<img src={API.base_image + this.card_img} />
</div>
<SearchForm handleContent={this.handleContent.bind(this)} />
</div>
<div className="collection_right">
{this.navigation()}<br />
<CardList cards={this.content.slice(this.n * (this.p-1), this.n * this.p)} setImage={this.setImage.bind(this)}/>
{this.navigation()}
</div>
</div>
);
}
output = () => {
let elements = this.content.slice(this.n * (this.p-1), this.n * this.p);
if (elements.length == 1 && elements[0].text) {
return (
<div style={{textAlign: 'left'}}>{elements[0].text}</div>
);
}
return elements.map((card, i) => {
switch (card.gsx$type) {
case "Attack":
return (<Attack attack={card} key={i} />);
case "Battlegear":
return (<Battlegear battlegear={card} key={i} />);
case "Creature":
return (<Creature creature={card} key={i} />);
case "Location":
return (<Location location={card} key={i} />);
case "Mugic":
return (<Mugic mugic={card} key={i} />);
default:
return (<div key={i}>Invalid Type</div>);
}
});
}
navigation() {
let numpages = Math.ceil(this.content.length / this.n);
@ -124,13 +107,14 @@ export default class CollectionHome extends React.Component {
<div style={{textAlign: 'left'}}>
<p>Showing page {this.p} of {numpages} {prev()} {next()}</p>
<p>
Entries per page:&nbsp;{this.n}&nbsp;
Entries per page:&nbsp;
{/*<input type="text" style={{width: '40px'}} value={this.n}
onChange={(event) => {let x = event.target.value; if (!isNaN(x)) this.n=x;}
/>*/}
<input type="button" value="10" onClick={(e) => this.n=e.target.value} />&nbsp;
<input type="button" value="20" onClick={(e) => this.n=e.target.value} />&nbsp;
<input type="button" value="50" onClick={(e) => this.n=e.target.value} />
<input type="button" value="5" disabled={this.n=="5"} onClick={(e) => this.n=e.target.value} />&nbsp;
<input type="button" value="10" disabled={this.n=="10"} onClick={(e) => this.n=e.target.value} />&nbsp;
<input type="button" value="20" disabled={this.n=="20"} onClick={(e) => this.n=e.target.value} />&nbsp;
<input type="button" value="50" disabled={this.n=="50"} onClick={(e) => this.n=e.target.value} />
</p>
</div>
);

View File

@ -0,0 +1,38 @@
import React from 'react';
import {observable} from "mobx";
import {observer, inject} from 'mobx-react';
import Attack from './Attack';
import Battlegear from './Battlegear';
import Creature from './Creature';
import Location from './Location';
import Mugic from './Mugic';
@inject((stores, props, context) => props) @observer
export default class CardList extends React.Component {
render() {
let cards = this.props.cards;
if (cards.length == 1 && cards[0].text) {
return (
<div style={{textAlign: 'left'}}>{cards[0].text}</div>
);
}
return cards.map((card, i) => {
switch (card.gsx$type) {
case "Attack":
return (<Attack attack={card} key={i} setImage={this.props.setImage.bind(this)}/>);
case "Battlegear":
return (<Battlegear battlegear={card} key={i} setImage={this.props.setImage.bind(this)}/>);
case "Creature":
return (<Creature creature={card} key={i} setImage={this.props.setImage.bind(this)}/>);
case "Location":
return (<Location location={card} key={i} setImage={this.props.setImage.bind(this)}/>);
case "Mugic":
return (<Mugic mugic={card} key={i} setImage={this.props.setImage.bind(this)}/>);
default:
return (<div key={i}>Invalid Type</div>);
}
});
}
}

View File

@ -20,6 +20,10 @@ export default class SearchForm extends React.Component {
this.filter = new loki("filter.db");
}
componentDidMount() {
this.search();
}
reset = () => {
this.type = "";
this.stones = {};
@ -38,58 +42,87 @@ export default class SearchForm extends React.Component {
let setsInput = [];
for (const key in API.sets) {
setsInput.push(<label key={key}><input type="checkbox" ref={(input) => this.sets[key] = input} />{API.sets[key]}</label>);
setsInput.push(<label style={{display: 'block'}} key={key}><input type="checkbox" ref={(input) => this.sets[key] = input} />{API.sets[key]}</label>);
}
return (
const card_type = (
<label>
Type:&nbsp;
<select onChange={(e) => {this.type = e.target.value}} >
<option value=""></option>
<option value="Attack">Attack</option>
<option value="Battlegear">Battlegear</option>
<option value="Creature">Creature</option>
<option value="Location">Location</option>
<option value="Mugic">Mugic</option>
</select>
</label>
);
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>
<input type="checkbox" ref={(input) => this.tribes.danian = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/danian.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes.mipedian = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/mipedian.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes.overworld = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/overworld.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes.underworld = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/underworld.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes["m'arrillian"] = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/m'arrillian.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes.generic = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/generic.png"} />
</div>
);
const card_elements = (
<div>
<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"} />
<input type="checkbox" ref={(input) => this.elements.fire = input}/><img height="16px"className="icon" src={"/src/img/icons/elements/fire.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.elements.air = input}/><img height="16px"className="icon" src={"/src/img/icons/elements/air.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.elements.earth = input}/><img height="16px"className="icon" src={"/src/img/icons/elements/earth.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.elements.water = input}/><img height="16px"className="icon" src={"/src/img/icons/elements/water.png"} />
<br />
<input type="checkbox" ref={(input) => this.stones.noElements = input}/><span>No Elements</span>
</div>
);
const card_disciplines = (
<div>
<input type="text" style={{width: '30px'}} ref={(input) => this.stones.courage = input} /><img className="icon" src={"/src/img/icons/disciplines/courage.png"} />&nbsp;
<input type="text" style={{width: '30px'}} ref={(input) => this.stones.power = input} /><img className="icon" src={"/src/img/icons/disciplines/power.png"} />&nbsp;
<input type="text" style={{width: '30px'}} ref={(input) => this.stones.wisdom = input} /><img className="icon" src={"/src/img/icons/disciplines/wisdom.png"} />&nbsp;
<input type="text" style={{width: '30px'}} ref={(input) => this.stones.speed = input} /><img className="icon" src={"/src/img/icons/disciplines/speed.png"} />
</div>
);
return (
<div className="SearchForm">
<form onSubmit={this.search}>
<label>Name: <input type="text" ref={(input) => this.stones.name = input} /></label>&nbsp;&nbsp;
<p>
Since not all data has been entered not all cards are listed, to see incomplete cards, click&nbsp;
<label>"Show all cards":<input type="checkbox" ref={(input) => this.stones.allCards = input}/></label>
</p>
<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 /><br />
<label>
Type:&nbsp;
<select onChange={(e) => {this.type = e.target.value}} >
<option value=""></option>
<option value="Attack">Attack</option>
<option value="Battlegear">Battlegear</option>
<option value="Creature">Creature</option>
<option value="Location">Location</option>
<option value="Mugic">Mugic</option>
</select>
</label>&nbsp;&nbsp;
<br />
{card_type}
<br />
<label>Subtypes: <input type="text" ref={(input) => this.stones.subtypes = input} /></label>
<br /><br />
<div>{setsInput}</div>
<br />
<div>
<label><input type="checkbox" ref={(input) => this.rarity["Common"] = input}/>Common</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.rarity["Uncommon"] = input}/>Uncommon</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.rarity["Rare"] = input}/>Rare</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.rarity["Super Rare"] = input}/>Super Rare</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.rarity["Ultra Rare"] = input}/>Ultra Rare</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.rarity["Promo"] = input}/>Promo</label>
</div>
<br />
<div>
<input type="checkbox" ref={(input) => this.tribes.danian = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/danian.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes.mipedian = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/mipedian.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes.overworld = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/overworld.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes.underworld = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/underworld.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes["m'arrillian"] = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/m'arrillian.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.tribes.generic = input}/><img height="16" className="icon" src={"/src/img/icons/tribes/generic.png"} />
</div>
<br />
<div>
<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"} />
<input type="checkbox" ref={(input) => this.elements.fire = input}/><img height="16" className="icon" src={"/src/img/icons/elements/fire.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.elements.air = input}/><img height="16" className="icon" src={"/src/img/icons/elements/air.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.elements.earth = input}/><img height="16" className="icon" src={"/src/img/icons/elements/earth.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.elements.water = input}/><img height="16" className="icon" src={"/src/img/icons/elements/water.png"} />&nbsp;
<input type="checkbox" ref={(input) => this.stones.noElements = input}/><span>No Elements</span>
</div>
<br />
<div>{setsInput}</div><br />
{card_rarity}<br />
{card_tribes}<br />
{card_elements}<br />
<div>
<span>Mugic Counters/Cost</span>&nbsp;
<label>Min: <input type="text" style={{width: '20px'}} ref={(input) => this.mc.min = input} /></label>&nbsp;
@ -114,21 +147,14 @@ export default class SearchForm extends React.Component {
<label>Max: <input type="text" style={{width: '20px'}} ref={(input) => this.base.max = input} /></label>
</div>
<br />
<div>
<span>Disciplines</span>&nbsp;
<label>Min <img height="16" className="icon" src={"/src/img/icons/disciplines/courage.png"} />: <input type="text" style={{width: '30px'}} ref={(input) => this.stones.courage = input} /></label>&nbsp;
<label>Min <img height="16" className="icon" src={"/src/img/icons/disciplines/power.png"} />: <input type="text" style={{width: '30px'}} ref={(input) => this.stones.power = input} /></label>&nbsp;
<label>Min <img height="16" className="icon" src={"/src/img/icons/disciplines/wisdom.png"} />: <input type="text" style={{width: '30px'}} ref={(input) => this.stones.wisdom = input} /></label>&nbsp;
<label>Min <img height="16" className="icon" src={"/src/img/icons/disciplines/speed.png"} />: <input type="text" style={{width: '30px'}} ref={(input) => this.stones.speed = input} /></label>
</div>
{card_disciplines}
<br />
<div>
<label><input type="checkbox" ref={(input) => this.stones.unique = input}/>Unique</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.stones.loyal = input}/>Loyal</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.stones.legendary = input}/>Legendary</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.stones.past = input}/>Past</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.stones.mirage = input}/>Mirage</label>
</div>
<label><input type="checkbox" ref={(input) => this.stones.unique = input}/>Unique</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.stones.loyal = input}/>Loyal</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.stones.legendary = input}/>Legendary</label>
<br />
<label><input type="checkbox" ref={(input) => this.stones.past = input}/>Past</label>&nbsp;
<label><input type="checkbox" ref={(input) => this.stones.mirage = input}/>Mirage</label>
<br />
<label>Initiative: <input type="text" ref={(input) => this.stones.initiative = input} /></label>
<br />
@ -138,12 +164,6 @@ export default class SearchForm extends React.Component {
<label><input type="checkbox" ref={(input) => this.gender.Male = input}/>Male</label>
</div>
<br />
<p>
Since not all data has been entered not all cards are listed,<br />
to see incomplete cards, click&nbsp;
<label>"Show all cards":<input type="checkbox" ref={(input) => this.stones.allCards = input}/></label>
</p>
<br />
<input type="submit" value="Search" />&nbsp;&nbsp;
<input type="button" value="Reset" disabled onClick={this.reset} />
</form>
@ -153,8 +173,10 @@ export default class SearchForm extends React.Component {
// TODO advanced filters
search = (e) => {
e.preventDefault();
e.stopPropagation();
if (e) {
e.preventDefault();
e.stopPropagation();
}
// Sort data descending alphabetically
let filter = this.filter.addCollection('filter');
var pview = filter.addDynamicView('filter');
@ -187,6 +209,10 @@ export default class SearchForm extends React.Component {
{'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')}}

18
src/css/collection.css Normal file
View File

@ -0,0 +1,18 @@
.collection_left {
width: 30%;
float: left;
}
.collection_right {
width: 70%;
float: right;
}
.card_img {
width: 250px;
height: 350px;
}
.SearchForm {
text-align: left;
}

View File

@ -88,7 +88,7 @@
}
/*-------------- Center Column --------------*/
.center-column {
width: 80% !important;
width: 60% !important;
margin: 0 auto;
/*float:left;*/
/*width:392px !important;*/
@ -100,7 +100,14 @@
/*width:269px;*/
float:left;
}
/*-------------- Full Column --------------*/
.full-column {
width: 98% !important;
margin: 0 auto;
/*float:left;*/
/*width:392px !important;*/
/*margin:0 6px 0 6px;*/
}
/*-------------- Background --------------*/
/*------------------------------------------------------*/
.fix-pgBkgrnd-repeat-x, .fix-img-bkgrnd {
@ -620,14 +627,14 @@
clear:both;
}
.content-left-btm-repeat-x{
width:95%; height:22px;
width:98%; height:22px;
background-image:url(../img/base/content-btm-repeat-x.jpg);
background-position:top left;
background-repeat:repeat-x;
float:right; clear:both;
}
.content-right-btm-repeat-x{
width:95%; height:22px;
width:98%; height:22px;
background-image:url(../img/base/content-btm-repeat-x.jpg);
background-position:top left;
background-repeat:repeat-x;