Skip to content

Commit

Permalink
Adding rotation of the sponsor logos. (betaflight#3888)
Browse files Browse the repository at this point in the history
  • Loading branch information
blckmn authored and chmelevskij committed Apr 27, 2024
1 parent 4a7db63 commit 18ef1d7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/js/BuildApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,13 @@ export default class BuildApi {

loadSponsorTile(mode, page, onSuccess, onFailure) {
const url = `${this._url}/api/configurator/sponsors/${mode}/${page}`;
this.load(url, onSuccess, onFailure);
$.get(url, function (data) {
onSuccess(data);
}).fail(xhr => {
if (onFailure !== undefined) {
onFailure();
}
});
}

sendAnalytics(type, parcel) {
Expand Down
21 changes: 16 additions & 5 deletions src/js/Sponsor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@ export default class Sponsor {

constructor () {
this._api = new BuildApi();
this._timer = setInterval(() => { this.Refresh(); }, 30000);
}

loadSponsorTile(name, div) {
Refresh() {
if (!navigator.onLine) {
return;
}

this._api.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light', name,
if (!this._div) {
return;
}

this._api.loadSponsorTile(DarkTheme.enabled ? 'dark' : 'light', this._name,
(content) => {
if (content) {
div.html(content);
div.show();
this._div.html(content);
this._div.show();
} else {
div.hide();
this._div.hide();
}
},
);
}

loadSponsorTile(name, div) {
this._name = name;
this._div = div;
this.Refresh();
}
}

0 comments on commit 18ef1d7

Please sign in to comment.