-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter.js
32 lines (31 loc) · 1.16 KB
/
counter.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
'use strict';
new Vue({
el: '#app',
data: {
totalDownloads: 0,
downloads: {
'symfony/symfony': 0,
'laravel/laravel': 0,
'yiisoft/yii': 0,
'codeigniter/framework': 0,
'cakephp/cakephp': 0,
'slim/slim': 0
}
},
created: function() {
var resource = this.$resource('https://packagist.org/packages/{package}.json?nocache={random}');
setInterval(() => {
for (let framework in this.downloads) {
resource.get({package: framework, random: Math.random()}).then((response) => {
let downloads = response.body.package.downloads.total;
if (this.downloads[framework] != downloads) {
if (this.downloads[framework] == 0) this.downloads[framework] = downloads;
this.totalDownloads += downloads - this.downloads[framework];
console.log(framework, ': +', downloads - this.downloads[framework]);
this.downloads[framework] = downloads;
}
});
}
}, 500);
}
});