2018-07-03 20:54:00 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import { computed } from '@ember/object';
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
timerTicks: 0,
|
|
|
|
|
|
|
|
startTimer: function() {
|
|
|
|
this.set(
|
|
|
|
'timer',
|
|
|
|
setInterval(() => {
|
|
|
|
this.incrementProperty('timerTicks');
|
|
|
|
}, 1000)
|
|
|
|
);
|
|
|
|
}.on('init'),
|
|
|
|
|
|
|
|
willDestroy() {
|
2019-03-26 07:46:44 +00:00
|
|
|
clearInterval(this.timer);
|
2018-07-03 20:54:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
denominator: computed('timerTicks', function() {
|
|
|
|
return Math.round(Math.random() * 1000);
|
|
|
|
}),
|
|
|
|
|
|
|
|
percentage: computed('timerTicks', function() {
|
|
|
|
return Math.round(Math.random() * 100) / 100;
|
|
|
|
}),
|
|
|
|
|
|
|
|
numerator: computed('denominator', 'percentage', function() {
|
2019-03-26 07:46:44 +00:00
|
|
|
return Math.round(this.denominator * this.percentage * 100) / 100;
|
2018-07-03 20:54:00 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
liveDetails: computed('denominator', 'numerator', 'percentage', function() {
|
|
|
|
return this.getProperties('denominator', 'numerator', 'percentage');
|
|
|
|
}),
|
|
|
|
});
|