From 5896a1c0eb7a4b7ab2b57dfde6d477f95789d82c Mon Sep 17 00:00:00 2001 From: Xaekai Date: Thu, 7 Jul 2016 06:53:06 -0700 Subject: [PATCH] Add timestamps to polls. Closes #562 --- package.json | 4 ++-- src/channel/poll.js | 4 +++- src/poll.js | 4 +++- www/js/callbacks.js | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 838072bd..f2d4e567 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.17.5", + "version": "3.18.2", "repository": { "url": "http://github.com/calzoneman/sync" }, @@ -25,13 +25,13 @@ "express-minify": "^0.1.6", "graceful-fs": "^4.1.2", "http-errors": "^1.3.1", - "jade": "^1.11.0", "json-typecheck": "^0.1.3", "lodash": "^4.13.1", "morgan": "^1.6.1", "mysql": "^2.9.0", "nodemailer": "^1.4.0", "oauth": "^0.9.12", + "pug": "^2.0.0-beta3", "q": "^1.4.1", "redis": "^2.4.2", "sanitize-html": "git://github.com/calzoneman/sanitize-html", diff --git a/src/channel/poll.js b/src/channel/poll.js index 2257e082..da6fa9c8 100644 --- a/src/channel/poll.js +++ b/src/channel/poll.js @@ -43,6 +43,7 @@ PollModule.prototype.load = function (data) { this.poll.options = data.poll.options; this.poll.counts = data.poll.counts; 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, counts: this.poll.counts, votes: this.poll.votes, - obscured: this.poll.obscured + obscured: this.poll.obscured, + timestamp: this.poll.timestamp }; }; diff --git a/src/poll.js b/src/poll.js index 64b1454a..411b92c1 100644 --- a/src/poll.js +++ b/src/poll.js @@ -17,6 +17,7 @@ var Poll = function(initiator, title, options, obscured) { this.counts[i] = 0; } this.votes = {}; + this.timestamp = Date.now(); } Poll.prototype.vote = function(ip, option) { @@ -46,7 +47,8 @@ Poll.prototype.packUpdate = function (showhidden) { title: this.title, options: this.options, counts: counts, - initiator: this.initiator + initiator: this.initiator, + timestamp: this.timestamp }; return packed; } diff --git a/www/js/callbacks.js b/www/js/callbacks.js index caa6da21..8e64811d 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -937,6 +937,8 @@ Callbacks = { })(i); } + $("").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")); },