Show seconds in timestamp

This commit is contained in:
Niko Bews 2017-05-06 21:44:57 +03:00
parent 691f628e48
commit fd983a7f6b
5 changed files with 23 additions and 3 deletions

View file

@ -901,8 +901,7 @@ kbd {
#chat .time {
color: #ddd;
text-align: right;
width: 46px;
padding-left: 10px;
}
#chat .from {

View file

@ -249,6 +249,12 @@
Show quits
</label>
</div>
<div class="col-sm-6">
<label class="opt">
<input type="checkbox" name="showSeconds">
Show seconds in timestamp
</label>
</div>
<div class="col-sm-12">
<h2>Visual Aids</h2>
</div>

View file

@ -54,7 +54,13 @@ const commands = [
"/whois"
];
const timeFormats = {
msgDefault: "HH:mm",
msgWithSeconds: "HH:mm:ss"
};
module.exports = {
colorCodeMap: colorCodeMap,
timeFormats: timeFormats,
commands: commands
};

View file

@ -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);
};

View file

@ -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");