-
-
Notifications
You must be signed in to change notification settings - Fork 858
/
Sponsor.js
40 lines (34 loc) · 957 Bytes
/
Sponsor.js
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
import BuildApi from './BuildApi';
import DarkTheme from './DarkTheme';
export default class Sponsor {
constructor () {
this._api = new BuildApi();
this._timer = setInterval(() => { this.Refresh(); }, 30000);
}
Refresh() {
if (!navigator.onLine) {
return;
}
if (!this._div) {
return;
}
this._api.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light', this._name,
(content) => {
if (content) {
this._div.fadeOut(500, () => {
this._div.html(content);
this._div.fadeIn(500);
});
this._div.show();
} else {
this._div.hide();
}
},
);
}
loadSponsorTile(name, div) {
this._name = name;
this._div = div;
this.Refresh();
}
}