From fd983a7f6b70c48f25e8bf7e0381ac585b9d6091 Mon Sep 17 00:00:00 2001 From: Niko Bews Date: Sat, 6 May 2017 21:44:57 +0300 Subject: [PATCH] Show seconds in timestamp --- client/css/style.css | 3 +-- client/index.html | 6 ++++++ client/js/constants.js | 6 ++++++ client/js/libs/handlebars/tz.js | 5 ++++- client/js/options.js | 6 ++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/client/css/style.css b/client/css/style.css index 9f731c39..65f3f206 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -901,8 +901,7 @@ kbd { #chat .time { color: #ddd; - text-align: right; - width: 46px; + padding-left: 10px; } #chat .from { diff --git a/client/index.html b/client/index.html index 5c11b2f6..80477b7d 100644 --- a/client/index.html +++ b/client/index.html @@ -249,6 +249,12 @@ Show quits +
+ +

Visual Aids

diff --git a/client/js/constants.js b/client/js/constants.js index 5c5811fd..c001cbaf 100644 --- a/client/js/constants.js +++ b/client/js/constants.js @@ -54,7 +54,13 @@ const commands = [ "/whois" ]; +const timeFormats = { + msgDefault: "HH:mm", + msgWithSeconds: "HH:mm:ss" +}; + module.exports = { colorCodeMap: colorCodeMap, + timeFormats: timeFormats, commands: commands }; diff --git a/client/js/libs/handlebars/tz.js b/client/js/libs/handlebars/tz.js index 77feaaff..2e807d52 100644 --- a/client/js/libs/handlebars/tz.js +++ b/client/js/libs/handlebars/tz.js @@ -1,7 +1,10 @@ "use strict"; const moment = require("moment"); +const constants = require("../../constants"); module.exports = function(time) { - return moment(time).format("HH:mm"); + const options = require("../../options"); + const format = options.showSeconds ? constants.timeFormats.msgWithSeconds : constants.timeFormats.msgDefault; + return moment(time).format(format); }; diff --git a/client/js/options.js b/client/js/options.js index 24265a56..205e9b13 100644 --- a/client/js/options.js +++ b/client/js/options.js @@ -3,6 +3,7 @@ const $ = require("jquery"); const settings = $("#settings"); const userStyles = $("#user-specified-css"); const storage = require("./localStorage"); +const tz = require("./libs/handlebars/tz"); const windows = $("#windows"); const chat = $("#chat"); @@ -19,6 +20,7 @@ const options = $.extend({ notifyAllMessages: false, part: true, quit: true, + showSeconds: false, theme: $("#theme").attr("href").replace(/^themes\/(.*).css$/, "$1"), // Extracts default theme name, set on the server configuration thumbnails: true, userStyles: userStyles.text(), @@ -80,6 +82,10 @@ settings.on("change", "input, select, textarea", function() { // otherwise, users get notifications for everything return h !== ""; }); + } else if (name === "showSeconds") { + chat.find(".msg > .time").each(function() { + $(this).text(tz($(this).parent().data("time"))); + }); } }).find("input") .trigger("change");