File size: 861 Bytes
e7c953d | 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 | 'use strict';
var propertyFilter = ['__v', '_id', '_user', '_song', 'songid', 'userid', 'roomid'];
function PlayModel(data) {
this.id = data._id;
this.user = data.userid;
this.updubs = 0;
this.grabs = 0;
this.downdubs = 0;
for (var key in data) {
if (data.hasOwnProperty(key) && propertyFilter.indexOf(key) === -1) this[key] = data[key];
}
this.dubs = {};
this.media = undefined;
}
PlayModel.prototype.getTimeElapsed = function() {
return Math.min(this.songLength, Date.now() - this.played);
};
PlayModel.prototype.getTimeRemaining = function() {
return Math.max(0, this.played + this.songLength - Date.now());
};
PlayModel.prototype.getScore = function() {
return {updubs: this.updubs, grabs: this.grabs, downdubs: this.downdubs};
};
module.exports = PlayModel;
|