-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeck.js
More file actions
30 lines (30 loc) · 1.09 KB
/
deck.js
File metadata and controls
30 lines (30 loc) · 1.09 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
onPage('Decks', function deckPage() {
debug('Deck editor');
eventManager.on('jQuery', () => {
$(document).ajaxSuccess((event, xhr, options) => {
if (options.url !== 'DecksConfig' || !options.data) return;
const data = JSON.parse(options.data);
const obj = Object.freeze({ data, options, xhr });
eventManager.emit('Deck:Change', obj);
eventManager.emit(`Deck:${data.action}`, obj);
});
$(document).ajaxComplete((event, xhr, options) => {
if (options.url !== 'DecksConfig') return;
if (options.type === 'GET') {
eventManager.emit('Deck:Loaded', xhr.responseJSON);
return;
}
const data = JSON.parse(options.data);
const obj = Object.freeze({ data, options, xhr });
eventManager.emit('Deck:postChange', obj);
eventManager.emit(`Deck:${data.action}`, obj);
});
// Class change
$('#selectSouls').change(function soulChange() {
// Sometimes it takes too long, so lets change it now
const val = $(this).val();
globalSet('soul', val);
eventManager.emit('Deck:Soul', val);
});
});
});