-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
22 lines (19 loc) · 785 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
let liveValue, targetValue, startAt, percentage;
let setProgress = function(value) {
document.getElementById('meine-status-bar').style.backgroundSize = value + '%';
};
window.addEventListener('onWidgetLoad', function (obj) {
let data=obj["detail"]["session"]["data"];
let fieldData=obj["detail"]["fieldData"];
liveValue=data["subscriber-points"]["amount"];
targetValue=fieldData.targetValue;
startAt=fieldData.startAt;
percentage = ((liveValue - startAt) / (targetValue - startAt)) * 100;
setProgress(percentage);
});
window.addEventListener('onEventReceived', function (obj) {
if (obj.detail.listener == "subscriber-latest") {
liveValue ++;
percentage = ((liveValue - startAt) / (targetValue - startAt)) * 100;
setProgress(percentage);}
});