Skip to content

Commit

Permalink
ubg cardbacks
Browse files Browse the repository at this point in the history
SQUASHED: AUTO-COMMIT-src-components-widgets-ubg-cards-entry.js,AUTO-COMMIT-src-components-widgets-ubg-cards.js,
  • Loading branch information
onsetsu committed Mar 11, 2024
1 parent b4f71b6 commit 107ca99
Show file tree
Hide file tree
Showing 2 changed files with 285 additions and 95 deletions.
34 changes: 21 additions & 13 deletions src/components/widgets/ubg-cards-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,28 @@ export default class UBGCardEntry extends Morph {
}

updateToFilter(filter) {
filter = filter.toLowerCase();

const card = this.card;
const id = card.getId();
const name = card.getName();
const cardType = card.getType()
const element = card.getElement();
const cost = card.getCost();
const text = card.getText();
const notes = card.getNotes();
const tags = card.getTags().join(' ');
const aspects = [id, name, cardType, element, cost, text, notes, tags];
let matching

const matching = aspects.some(aspect => (aspect + '').toLowerCase().match(new RegExp(filter, 'gmi')));
if (filter.startsWith('>')) {
let functionBody = 'return ' + filter.substring(1).trim();
let filterFunction = new Function('c', functionBody);
matching = !!filterFunction(this.card)
} else {
filter = filter.toLowerCase();

const card = this.card;
const id = card.getId();
const name = card.getName();
const cardType = card.getType()
const element = card.getElement();
const cost = card.getCost();
const text = card.getText();
const notes = card.getNotes();
const tags = card.getTags().join(' ');
const aspects = [id, name, cardType, element, cost, text, notes, tags];

matching = aspects.some(aspect => (aspect + '').toLowerCase().match(new RegExp(filter, 'gmi')));
}

this.classList.toggle('match', matching);
this.classList.toggle('hidden', !matching);
Expand Down
Loading

0 comments on commit 107ca99

Please sign in to comment.