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 { #chat .time {
color: #ddd; color: #ddd;
text-align: right; padding-left: 10px;
width: 46px;
} }
#chat .from { #chat .from {

View file

@ -249,6 +249,12 @@
Show quits Show quits
</label> </label>
</div> </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"> <div class="col-sm-12">
<h2>Visual Aids</h2> <h2>Visual Aids</h2>
</div> </div>

View file

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

View file

@ -1,7 +1,10 @@
"use strict"; "use strict";
const moment = require("moment"); const moment = require("moment");
const constants = require("../../constants");
module.exports = function(time) { 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 settings = $("#settings");
const userStyles = $("#user-specified-css"); const userStyles = $("#user-specified-css");
const storage = require("./localStorage"); const storage = require("./localStorage");
const tz = require("./libs/handlebars/tz");
const windows = $("#windows"); const windows = $("#windows");
const chat = $("#chat"); const chat = $("#chat");
@ -19,6 +20,7 @@ const options = $.extend({
notifyAllMessages: false, notifyAllMessages: false,
part: true, part: true,
quit: true, quit: true,
showSeconds: false,
theme: $("#theme").attr("href").replace(/^themes\/(.*).css$/, "$1"), // Extracts default theme name, set on the server configuration theme: $("#theme").attr("href").replace(/^themes\/(.*).css$/, "$1"), // Extracts default theme name, set on the server configuration
thumbnails: true, thumbnails: true,
userStyles: userStyles.text(), userStyles: userStyles.text(),
@ -80,6 +82,10 @@ settings.on("change", "input, select, textarea", function() {
// otherwise, users get notifications for everything // otherwise, users get notifications for everything
return h !== ""; return h !== "";
}); });
} else if (name === "showSeconds") {
chat.find(".msg > .time").each(function() {
$(this).text(tz($(this).parent().data("time")));
});
} }
}).find("input") }).find("input")
.trigger("change"); .trigger("change");