-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpreview.js
More file actions
53 lines (49 loc) · 1.41 KB
/
preview.js
File metadata and controls
53 lines (49 loc) · 1.41 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
51
52
53
settings.register({
name: 'Disable Deck Preview',
key: 'underscript.disable.deckPreview',
//hidden: typeof displayCardDeck === 'function',
onChange(val, val2) {
if (!onPage('Decks') || typeof cardHoverEnabled === 'undefined') return;
cardHoverEnabled = val === '0';
},
});
// TODO: Convert to event listeners?
onPage('Decks', function () {
function getCard(id, shiny) {
const el = decks[classe].find(card => card.id === id && card.shiny === shiny);
if (el) {
c = $('<div>');
appendCard(c, el); // external
return c;
}
}
function hoverCard(element) {
const id = element.attr('id');
const shiny = element.hasClass('shiny');
const card = getCard(parseInt(id), shiny);
if (!card) return hover.show('Unknown card');
return hover.show(card);
}
function checkHover(el) {
const hover = hoverCard(el);
return (e) => {
if (!settings.value('underscript.disable.deckPreview')) {
hover(e);
}
};
}
eventManager.on(':loaded', () => {
if (typeof displayCardDeck === 'function') {
cardHoverEnabled = !settings.value('underscript.disable.deckPreview');
return;
}
const oRefresh = refreshDeckList;
refreshDeckList = function newRefresh() {
oRefresh();
$('#deckCards li').each(function (index) {
const element = $(this);
element.hover(checkHover(element));
});
};
});
});