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 = {
username: username,
msg: msg,
msgclass: msgclass
msgclass: msgclass,
time: Date.now()
};
if(data) {
for(var key in data) {

View File

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

View File

@ -43,12 +43,13 @@ function parseBool(x) {
else return Boolean(x);
}
var USEROPTS = {
theme: readCookie("cytube_theme") || "default",
css: readCookie("cytube_css") || "",
layout: readCookie("cytube_layout") || "default",
synch: parseBool(readCookie("cytube_synch")) || true,
hidevid: parseBool(readCookie("cytube_hidevid")) || false,
modhat: parseBool(readCookie("cytube_modhat")) || false
theme : readCookie("cytube_theme") || "default",
css : readCookie("cytube_css") || "",
layout : readCookie("cytube_layout") || "default",
synch : parseBool(readCookie("cytube_synch")) || true,
hidevid : parseBool(readCookie("cytube_hidevid")) || false,
show_timestamps : parseBool(readCookie("cytube_show_timestamps")) || false,
modhat : parseBool(readCookie("cytube_modhat")) || false
};
applyOpts();
$("#optlink").click(showUserOpts);

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);
$("<strong/>").text("<" + data.username + "> ").appendTo(name);
$("<strong/>").text(data.username + ": ").appendTo(name);
var message = $("<span/>").appendTo(div);
message[0].innerHTML = data.msg;
if(data.modflair) {
@ -1055,6 +1060,13 @@ function showUserOpts() {
hidevid.prop("checked", USEROPTS.hidevid);
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) {
$("<hr>").appendTo(form);
var modhatcontainer = $("<label/>").addClass("checkbox")
@ -1070,11 +1082,12 @@ function showUserOpts() {
.appendTo(footer);
submit.click(function() {
USEROPTS.theme = themeselect.val();
USEROPTS.css = usercss.val();
USEROPTS.layout = layoutselect.val();
USEROPTS.synch = synch.prop("checked");
USEROPTS.hidevid= hidevid.prop("checked");
USEROPTS.theme = themeselect.val();
USEROPTS.css = usercss.val();
USEROPTS.layout = layoutselect.val();
USEROPTS.synch = synch.prop("checked");
USEROPTS.hidevid = hidevid.prop("checked");
USEROPTS.show_timestamps = showts.prop("checked");
if(RANK >= Rank.Moderator) {
USEROPTS.modhat = modhat.prop("checked");
}