File size: 3,366 Bytes
7aec436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
  <head>
    <meta name="robots" content="noindex">
    <style>

      body {

        font-family: sans-serif;

      }

      td {

        text-align: center;

      }

      a {

        text-decoration: none;

      }

      a:hover {

        text-decoration: underline;

      }

    </style>
  </head>
  <body>
    <h1>Packager Standalone</h1>
    <p>Note: These download counts are <i>especially</i> unreliable due to some automated file downloads for the desktop app.</p>
    <main id="packager"><p>Loading...</p></main>
    <h1>Packager Extras</h1>
    <main id="packager-extras"><p>Loading...</p></main>
    <script>

      const fetchStats = (repo, main) => {

        fetch(`https://api.github.com/repos/${repo}/releases?per_page=100`)

          .then((r) => {

            if (!r.ok) throw new Error('Unexpected status code: ' + r.status);

            return r.json();

          })

          .then((releases) => {

            while (main.firstChild) main.removeChild(main.firstChild);



            for (const {assets, tag_name, html_url, prerelease} of releases) {

              if (prerelease) {

                continue;

              }



              const table = document.createElement('table');

              table.border = '1';



              const headerRow = document.createElement('tr');

              headerRow.appendChild(Object.assign(document.createElement('th'), {

                textContent: 'Asset'

              }));

              headerRow.appendChild(Object.assign(document.createElement('th'), {

                textContent: 'Downloads'

              }));

              table.appendChild(headerRow);



              for (const {download_count, name, browser_download_url} of assets.sort((a,b) => {

                if (a.name > b.name) return 1;

                if (b.name > a.name) return -1;

                return 0;

              })) {

                if (name.endsWith('yml') || name.endsWith('blockmap')) continue;

                const link = Object.assign(document.createElement('a'), {

                  href: browser_download_url,

                  textContent: name

                });

                const row = document.createElement('tr');



                const downloadCell = document.createElement('td');

                downloadCell.appendChild(link);

                row.appendChild(downloadCell);



                row.appendChild(Object.assign(document.createElement('td'), {

                  textContent: download_count

                }));

                table.appendChild(row);

              }



              const tagLink = document.createElement('a');

              tagLink.href = html_url;

              tagLink.textContent = '*';



              const header = document.createElement('h2');

              header.textContent = `${tag_name} `;

              header.appendChild(tagLink);



              main.appendChild(header);

              main.appendChild(table);

            }

          })

          .catch((err) => {

            console.error(err);

            alert(err);

          });

      };

      fetchStats('TurboWarp/packager', document.querySelector('#packager'));

      fetchStats('TurboWarp/packager-extras', document.querySelector('#packager-extras'));

    </script>
  </body>
</html>