-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeckPreview.js
More file actions
38 lines (37 loc) · 1.14 KB
/
deckPreview.js
File metadata and controls
38 lines (37 loc) · 1.14 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
settings.register({
name: 'Disable Deck Preview',
key: 'underscript.disable.deckPreview',
});
// TODO: Convert to event listeners?
onPage('Decks', function () {
function hoverCard(element) {
const id = element.attr('id');
const shiny = element.hasClass('shiny') ? '.shiny' : '';
const card = $(`table#${id}${shiny}:lt(1)`).clone();
if (card.length !== 1) return;
card.find('#quantity').remove();
if (card.css('opacity') !== '1') card.css('opacity', 1);
loadCard(card);
return hover.show(card);
}
// Initial load
eventManager.on('jQuery', () => {
function checkHover(el) {
const hover = hoverCard(el);
return (e) => {
if (!settings.value('underscript.disable.deckPreview')) {
hover(e);
}
};
}
$('li.list-group-item').each(function (index) {
const element = $(this);
element.hover(checkHover(element));
});
eventManager.on('Deck:removeCard', () => hover.hide());
eventManager.on('Deck:addCard', (data) => {
const element = $(`#deckCards${data.classe} li#${data.idCard}:last`);
element.hover(checkHover(element));
});
});
});