database will update if it has changed since last build

This commit is contained in:
Daniel
2019-07-05 22:18:54 -04:00
parent 5f21c580c8
commit 48a4777f10
8 changed files with 827 additions and 594 deletions

File diff suppressed because one or more lines are too long

View File

@@ -13,6 +13,13 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/*!
* cookie
* Copyright(c) 2012-2014 Roman Shtylman
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
/*
object-assign
(c) Sindre Sorhus
@@ -45,3 +52,21 @@ object-assign
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.8.6
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license mobx-react v5.4.4
* index.module.js
*
* Copyright (c) 2015 Michel Weststrate.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

File diff suppressed because one or more lines are too long

1317
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,8 +14,8 @@
"license": "MIT",
"dependencies": {
"lokijs": "^1.5.6",
"mobx": "^5.9.4",
"mobx-react": "^5.4.3",
"mobx": "^5.10.1",
"mobx-react": "^5.4.4",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-collapsible": "^2.6.0",
@@ -24,39 +24,40 @@
"react-interactive": "^0.8.3",
"react-onclickoutside": "^6.8.0",
"react-process-string": "^1.2.0",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-router": "^5.0.1",
"react-router-dom": "^5.0.1",
"universal-cookie": "^4.0.0",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/node": "^7.2.2",
"@babel/core": "^7.4.5",
"@babel/node": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.2.3",
"@babel/preset-env": "^7.4.5",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.4.4",
"babel-eslint": "^10.0.1",
"@babel/runtime": "^7.4.5",
"babel-eslint": "^10.0.2",
"babel-loader": "^8.0.5",
"css-loader": "^2.1.0",
"eslint": "^5.7.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"mini-css-extract-plugin": "^0.6.0",
"css-loader": "^3.0.0",
"eslint": "^6.0.1",
"eslint-config-airbnb": "^17.1.1",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.2",
"mini-css-extract-plugin": "^0.7.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"sass-loader": "^7.0.x",
"style-loader": "^0.23.1",
"uglifyjs-webpack-plugin": "^2.1.1",
"webpack": "^4.28.3",
"webpack-cli": "^3.2.0",
"webpack-dev-server": "^3.1.14"
"uglifyjs-webpack-plugin": "^2.1.3",
"webpack": "^4.35.2",
"webpack-cli": "^3.3.5",
"webpack-dev-server": "^3.7.2"
}
}

View File

@@ -1,6 +1,8 @@
import 'whatwg-fetch';
import loki from 'lokijs';
import {observable, observe, action} from "mobx";
import Cookies from 'universal-cookie';
const cookies = new Cookies();
class CollectionDB {
// Keeps track of what collections have been populated
@@ -31,7 +33,22 @@ class CollectionDB {
@action
async setupType(type, resolve) {
if (this.building.hasOwnProperty(type)) {
let uc_type = type.charAt(0).toUpperCase() + type.slice(1);
if (this.building[type].get() == "built") {
// Check if data has been updated
this.getSpreadsheetData(this.api.urls[uc_type][this.format], uc_type, (data) => {
let cookie = cookies.get(`${this.format}_${type}`);
if (cookie) {
if ((new Date(data[0].updated)) > (new Date(cookie))) {
this[type].clear();
this[type].insert(data);
cookies.set(`${this.format}_${type}`, data[0].updated, { path: '/' });
}
}
else {
cookies.set(`${this.format}_${type}`, data[0].updated, { path: '/' });
}
});
return resolve();
}
if (this.building[type].get() == "building") {
@@ -45,7 +62,6 @@ class CollectionDB {
this.building[type].set("building");
// check if the collection already exists in memory
if (this[type].data.length == 0) {
let uc_type = type.charAt(0).toUpperCase() + type.slice(1);
return this.getSpreadsheetData(this.api.urls[uc_type][this.format], uc_type, (data) => {
this[type].insert(data);
this.building[type].set("built");

View File

@@ -71,7 +71,7 @@ export default function search_api(input) {
{'gsx$ability': {"$or": textList}},
{'gsx$artist': {"$or": textList}}
]
if (input.flavor)
if (input.flavor)
list.splice(3, 0, {'gsx$flavortext': {"$or": textList}});
return list;
@@ -79,7 +79,7 @@ export default function search_api(input) {
attackResults = attackResults.find({'$or': parm});
battlegearResults = battlegearResults.find({'$or': parm});
creatureResults = creatureResults.find({'$or':
creatureResults = creatureResults.find({'$or':
(parm.concat([{'gsx$brainwashed': {"$or": textList}}]))
});
locationResults = locationResults.find({'$or': parm});
@@ -113,7 +113,7 @@ export default function search_api(input) {
creatureResults = creatureResults.find({'gsx$types': {'$or': subtypesList} });
locationResults = locationResults.find({'gsx$initiative': {'$or': subtypesList}});
attackResults = attackResults.limit(0);
battlegearResults = battlegearResults.limit(0);
battlegearResults = battlegearResults.find({'gsx$types': {'$or': subtypesList} });
mugicResults = mugicResults.limit(0);
}
@@ -173,7 +173,7 @@ export default function search_api(input) {
});
if (el !== "") {
creatureResults = creatureResults.find({'gsx$elements':
creatureResults = creatureResults.find({'gsx$elements':
{'$regex': new RegExp("^" + el.substring(0, el.length-2) + "\s*$", 'i')}
});
}

View File

@@ -58,12 +58,12 @@ function Base(props) {
<ul id="unity-sprite" className={language}>
<li id="unity-nav1" className={language}></li>
<li id="unity-nav2" className={language}><Link to={`/collection/`}><span>Collect</span></Link></li>
<li id="unity-nav3" className={language}><a href="http://www.tradecardsonline.com/?action=selectCard&goal=DK&game_id=82"><span>Build</span></a></li>
<li id="unity-nav4" className={language}><a href="http://www.tradecardsonline.com/?action=selectCard&goal=&game_id=82"><span>Trade</span></a></li>
<li id="unity-nav3" className={language}><a href="http://chaoticbackup.forumotion.com/f11-deck-building"><span>Build</span></a></li>
<li id="unity-nav4" className={language}><a href="http://chaoticbackup.forumotion.com/f16-trading-buying-and-selling"><span>Trade</span></a></li>
<li id="unity-nav5" className={language}><Link to={`/`}><span>Home</span></Link></li>
<li id="unity-nav6" className={language}><a href="http://chaoticbackup.forumotion.com"><span>Forums</span></a></li>
<li id="unity-nav7" className={language}><Link to={`/portal/`}><span>Portal</span></Link></li>
<li id="unity-nav8" className={language}><a href="http://www.tradecardsonline.com/?action=selectCard&goal=DK&game_id=82"><span>Play</span></a></li>
<li id="unity-nav8" className={language}><a href="https://untap.in"><span>Play</span></a></li>
<li id="unity-nav9" className={language}></li>
</ul>
<ul id="unityETC-sprite" className={language}>