Add timestamps (optional) to chat messages

This commit is contained in:
calzoneman 2013-05-01 16:03:03 -05:00
parent 3600a3114a
commit d8894f0280
4 changed files with 32 additions and 13 deletions

View File

@ -1234,7 +1234,8 @@ Channel.prototype.sendMessage = function(username, msg, msgclass, data) {
var msgobj = { var msgobj = {
username: username, username: username,
msg: msg, msg: msg,
msgclass: msgclass msgclass: msgclass,
time: Date.now()
}; };
if(data) { if(data) {
for(var key in data) { for(var key in data) {

View File

@ -210,3 +210,7 @@ html, body {
text-align: center; text-align: center;
width: 100%; width: 100%;
} }
.timestamp {
font-size: 8pt;
}

View File

@ -48,6 +48,7 @@ var USEROPTS = {
layout : readCookie("cytube_layout") || "default", layout : readCookie("cytube_layout") || "default",
synch : parseBool(readCookie("cytube_synch")) || true, synch : parseBool(readCookie("cytube_synch")) || true,
hidevid : parseBool(readCookie("cytube_hidevid")) || false, hidevid : parseBool(readCookie("cytube_hidevid")) || false,
show_timestamps : parseBool(readCookie("cytube_show_timestamps")) || false,
modhat : parseBool(readCookie("cytube_modhat")) || false modhat : parseBool(readCookie("cytube_modhat")) || false
}; };
applyOpts(); applyOpts();

View File

@ -203,8 +203,13 @@ function formatChatMessage(data) {
} }
} }
} }
if(USEROPTS.show_timestamps) {
var time = $("<span/>").addClass("timestamp").appendTo(div);
var timestamp = new Date(data.time).toTimeString().split(" ")[0];
time.text("["+timestamp+"] ");
}
var name = $("<span/>").appendTo(div); var name = $("<span/>").appendTo(div);
$("<strong/>").text("<" + data.username + "> ").appendTo(name); $("<strong/>").text(data.username + ": ").appendTo(name);
var message = $("<span/>").appendTo(div); var message = $("<span/>").appendTo(div);
message[0].innerHTML = data.msg; message[0].innerHTML = data.msg;
if(data.modflair) { if(data.modflair) {
@ -1055,6 +1060,13 @@ function showUserOpts() {
hidevid.prop("checked", USEROPTS.hidevid); hidevid.prop("checked", USEROPTS.hidevid);
addOption("Hide Video", vidcontainer); addOption("Hide Video", vidcontainer);
var tscontainer = $("<label/>").addClass("checkbox")
.text("Show timestamps in chat");
var showts = $("<input/>").attr("type", "checkbox").appendTo(tscontainer);
showts.prop("checked", USEROPTS.show_timestamps);
addOption("Show timestamps", tscontainer);
if(RANK >= Rank.Moderator) { if(RANK >= Rank.Moderator) {
$("<hr>").appendTo(form); $("<hr>").appendTo(form);
var modhatcontainer = $("<label/>").addClass("checkbox") var modhatcontainer = $("<label/>").addClass("checkbox")
@ -1075,6 +1087,7 @@ function showUserOpts() {
USEROPTS.layout = layoutselect.val(); USEROPTS.layout = layoutselect.val();
USEROPTS.synch = synch.prop("checked"); USEROPTS.synch = synch.prop("checked");
USEROPTS.hidevid = hidevid.prop("checked"); USEROPTS.hidevid = hidevid.prop("checked");
USEROPTS.show_timestamps = showts.prop("checked");
if(RANK >= Rank.Moderator) { if(RANK >= Rank.Moderator) {
USEROPTS.modhat = modhat.prop("checked"); USEROPTS.modhat = modhat.prop("checked");
} }