X-Git-Url: http://git.scottworley.com/reliable-chat/blobdiff_plain/da9ce2ab933917db7d4d59606ae6845d78f35a98..bd1ed9dd102d04d543f2fad5737b91c1a5835316:/webclient/rc.html?ds=inline diff --git a/webclient/rc.html b/webclient/rc.html index ff78fc0..a062a17 100644 --- a/webclient/rc.html +++ b/webclient/rc.html @@ -114,9 +114,22 @@ } } + function rcformattime(t) { + var d = t.getDay(); + d = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][d]; + var h = t.getHours(); + var m = t.getMinutes(); + var s = t.getSeconds(); + function pad(x) { + return (x < 10 ? "0" : "") + x; + } + return d + " " + pad(h) + ":" + pad(m) + ":" + pad(s); + } + function rcaddmessagetohistory(message) { var d = document.createElement("div"); - d.appendChild(document.createTextNode(message)); + var text = (message.Time ? rcformattime(message.Time) : "") + " " + message.Text; + d.appendChild(document.createTextNode(text)); var h = document.getElementById("history"); h.appendChild(d); window.scrollTo(0, document.body.scrollHeight); @@ -129,10 +142,12 @@ function rcreceivemessages(server, messages) { for (var i in messages) { - var seen_key = make_seen_key(messages[i]['ID'], messages[i]['Text']); + var m = messages[i]; + m.Time = new Date(m.Time); + var seen_key = make_seen_key(m.ID, m.Text); if (!(seen_key in seen)) { seen[seen_key] = true; - rcaddmessagetohistory(messages[i]['Text']); + rcaddmessagetohistory(m); for (var i in servers) { rcchangeserverstatus(servers[i], "sad"); } @@ -154,7 +169,7 @@ rcreceivemessages(server, messages); delay = 40; if (messages.length >= 1 && "Time" in messages[messages.length-1]) { - since[server] = messages[messages.length-1]["Time"]; + since[server] = messages[messages.length-1].Time; } } } @@ -208,7 +223,7 @@ message = "<" + rcnick() + "> " + input; } - var d = rcaddmessagetohistory(message); + var d = rcaddmessagetohistory({'Text': message}); rcsend(d, message); }