-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathborders.js
More file actions
50 lines (44 loc) · 1.66 KB
/
borders.js
File metadata and controls
50 lines (44 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
settings.register({
name: 'Disable Crafting Highlight',
key: 'underscript.disable.craftingborder',
onChange: () => {
if (onPage('Crafting')) {
setTimeout(() => eventManager.emit('refreshhighlight'));
}
},
category: 'Crafting',
page: 'Library',
});
onPage('Crafting', function craftableCards() {
style.add(
'.craftable { box-shadow: 0 0 10px 2px #008000; transform: translate3d(0,0,0); }',
'.craftable td { border-color: #00cc00; }',
'.highlight-green { text-shadow: 0px 0px 10px #008000; color: #00cc00; }',
);
function highlight(el) {
const rarity = cardHelper.rarity(el);
const set = !settings.value('underscript.disable.craftingborder') &&
rarity !== 'DETERMINATION' &&
cardHelper.craft.quantity(el) < cardHelper.craft.max(rarity) &&
cardHelper.craft.cost(el) <= cardHelper.craft.totalDust();
el.classList.toggle('craftable', set);
}
function update({id, shiny, dust}) {
if (dust >= cardHelper.craft.cost('LEGENDARY', true)) {
debug('updating');
const el = cardHelper.find(id, shiny);
if (el) highlight(el);
else debug({id, shiny}, 'underscript.debugging.borders');
} else {
highlightCards();
}
}
function highlightCards() {
debug('highlighting');
document.querySelectorAll('table.cardBoard, table.card').forEach(highlight);
}
eventManager.on('craftcard', update);
eventManager.on('refreshhighlight', highlightCards);
eventManager.on('Craft:RefreshPage', () => eventManager.emit('refreshhighlight'));
fn.infoToast('Craftable cards are highlighted in <span class="highlight-green">green</span>', 'underscript.notice.craftingborder', '1')
});