-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeck.js
More file actions
34 lines (33 loc) · 1.24 KB
/
deck.js
File metadata and controls
34 lines (33 loc) · 1.24 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
import eventManager from 'src/utils/eventManager.js';
import { globalSet } from 'src/utils/global.js';
import onPage from 'src/utils/onPage.js';
onPage('Decks', function deckPage() {
eventManager.on('jQuery', () => {
$(document).ajaxSuccess((event, xhr, options) => {
if (options.url !== 'DecksConfig' || !options.data) return;
const { action } = JSON.parse(options.data);
const data = xhr.responseJSON;
const obj = Object.freeze({ action, data, options, xhr });
eventManager.emit('Deck:Change', obj);
eventManager.emit(`Deck:${action}`, obj);
});
$(document).ajaxComplete((event, xhr, options) => {
if (options.url !== 'DecksConfig') return;
const data = xhr.responseJSON;
if (options.type === 'GET') {
eventManager.singleton.emit('Deck:Loaded', data);
return;
}
const { action } = JSON.parse(options.data);
const obj = Object.freeze({ action, data, options, xhr });
eventManager.emit('Deck:postChange', obj);
eventManager.emit(`Deck:${action}`, obj);
});
// Soul change
globalSet('updateSoul', function updateSoul() {
this.super();
const val = $('#selectSouls').val();
eventManager.emit('Deck:Soul', val);
});
});
});