-
Notifications
You must be signed in to change notification settings - Fork 266
/
clover.js
57 lines (53 loc) · 1.67 KB
/
clover.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// show link to the latest clever firmware
gitbook.events.bind('page.change', function() {
if (!document.querySelector('a.latest-firmware')) return;
fetch('https://api.github.com/repos/CopterExpress/Firmware/releases').then(function (res) {
return res.json();
}).then(function (data) {
// look for stable release
let stable;
for (let release of data) {
let clever = (release.name.indexOf('clover') != -1) || (release.name.indexOf('clever') != -1);
if (clever && !release.prerelease && !release.draft) {
stable = release;
break;
}
}
// let el = document.querySelector('#download-latest-release');
// el.innerHTML = stable.name;
// el.href = stable.html_url;
// document.querySelector('#release').style.display = 'block';
for (let asset of stable.assets) {
let el;
if (asset.name == 'px4fmu-v4_default.px4') {
el = document.querySelector('a.latest-firmware.v4');
} else if (asset.name == 'px4fmu-v2_lpe.px4') {
el = document.querySelector('a.latest-firmware.v2');
}
if (el) {
el.href = asset.browser_download_url;
el.innerHTML = stable.name;
}
}
});
});
// show link to latest raspberry image
gitbook.events.bind('page.change', function() {
var el = document.querySelector('a.latest-image');
if (!el) return;
// get latest release from GitHub
fetch('https://api.github.com/repos/CopterExpress/clever/releases').then(function(res) {
return res.json();
}).then(function(data) {
// look for stable release
let stable;
for (let release of data) {
if (!release.prerelease && !release.draft) {
stable = release;
break;
}
}
el.innerHTML = stable.name;
el.href = stable.assets[0].browser_download_url;
});
});