This repository has been archived by the owner on Jan 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathindex.html
64 lines (58 loc) · 2.3 KB
/
index.html
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
58
59
60
61
62
63
64
<html>
<head>
<title>MiBand 5 & 6 watchface editor GUI</title>
</head>
<body>
<h1><a onclick="download()" name="download_button">Download<h1>
</body>
<script>
fetch("https://api.github.com/repos/Johnson070/MiBand-5-watchface-editor/releases").then(
function(response){
return response.json()
}).then(function(data){
var p = data.map(function(x){
if(typeof x.assets == 'undefined' || x.assets.length == 0){ return 0; }
sumDownloads = 0;
for (var i=0; i < x.assets.length;i++) {
sumDownloads += x.assets[i].download_count;
if (document.getElementsByName("download_button")[0].href.indexOf("github") == -1) {
document.getElementsByName("download_button")[0].href = x.assets[i].browser_download_url;
}
}
return sumDownloads;
});
var b = data.map(function(x){
if(typeof x.tag_name == 'undefined' || x.tag_name.length == 0){ return 0; }
return x.tag_name;
});
var sum = 0;
for(var i=0;i<p.length;i++){
sum += p[i];
}
var newUpdate = p[0];
document.querySelector('body').innerHTML += `<h2>Total downloads: <font color="red">${sum}</font></h2>`;
for (var i = 0; i < data.length;i++)
{
if(typeof data[i].assets == 'undefined' || data[i].assets.length == 0){ continue; }
sumDownloads = 0;
for (var j=0; j < data[i].assets.length;j++)
sumDownloads += data[i].assets[j].download_count;
document.querySelector('body').innerHTML += `<h3>${b[i]} Downloads: <font color="red">${sumDownloads}</font></h3>${
(new Date(data[i].published_at)).toString().substring(4,(new Date(data[i].published_at)).toString().indexOf("GMT"))}`;
}
});
function download(){
var p = data.map(function(x){
if(typeof x.assets == 'undefined' || x.assets.length == 0){ return 0; }
sumDownloads = 0;
for (var i=0; i < x.assets.length;i++) {
sumDownloads += x.assets[i].download_count;
if (document.getElementsByName("download_button")[0].href.indexOf("github") == -1) {
document.getElementsByName("download_button")[0].href = x.assets[i].browser_download_url;
}
}
return sumDownloads;
});
}
</script>
</html>