Merge pull request #589 from Xaekai/polltime

Add timestamps to polls
This commit is contained in:
Calvin Montgomery 2016-07-07 23:30:19 -07:00 committed by GitHub
commit 292efd2b71
4 changed files with 9 additions and 3 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.18.1", "version": "3.18.2",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -43,6 +43,7 @@ PollModule.prototype.load = function (data) {
this.poll.options = data.poll.options; this.poll.options = data.poll.options;
this.poll.counts = data.poll.counts; this.poll.counts = data.poll.counts;
this.poll.votes = data.poll.votes; this.poll.votes = data.poll.votes;
this.poll.timestamp = data.poll.timestamp;
} }
} }
}; };
@ -59,7 +60,8 @@ PollModule.prototype.save = function (data) {
options: this.poll.options, options: this.poll.options,
counts: this.poll.counts, counts: this.poll.counts,
votes: this.poll.votes, votes: this.poll.votes,
obscured: this.poll.obscured obscured: this.poll.obscured,
timestamp: this.poll.timestamp
}; };
}; };

View File

@ -17,6 +17,7 @@ var Poll = function(initiator, title, options, obscured) {
this.counts[i] = 0; this.counts[i] = 0;
} }
this.votes = {}; this.votes = {};
this.timestamp = Date.now();
} }
Poll.prototype.vote = function(ip, option) { Poll.prototype.vote = function(ip, option) {
@ -46,7 +47,8 @@ Poll.prototype.packUpdate = function (showhidden) {
title: this.title, title: this.title,
options: this.options, options: this.options,
counts: counts, counts: counts,
initiator: this.initiator initiator: this.initiator,
timestamp: this.timestamp
}; };
return packed; return packed;
} }

View File

@ -937,6 +937,8 @@ Callbacks = {
})(i); })(i);
} }
$("<span/>").addClass("label label-default pull-right").data('timestamp',data.timestamp).appendTo(poll)
.text(new Date(data.timestamp).toTimeString().split(" ")[0]);
poll.find(".btn").attr("disabled", !hasPermission("pollvote")); poll.find(".btn").attr("disabled", !hasPermission("pollvote"));
}, },