From 37ba46d37904a6b4e4aa6d974fc416edbf7fc206 Mon Sep 17 00:00:00 2001 From: Patrick Melanson Date: Mon, 18 Jul 2016 21:33:27 -0400 Subject: [PATCH 1/3] Extended fetchConfValue with callbacks --- js/connection.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/connection.js b/js/connection.js index 55e714a..65c9afc 100644 --- a/js/connection.js +++ b/js/connection.js @@ -320,7 +320,7 @@ weechat.factory('connection', }); }; - var fetchConfValue = function(name) { + var fetchConfValue = function(name, callback) { ngWebsockets.send( weeChat.Protocol.formatInfolist({ name: "option", @@ -329,6 +329,9 @@ weechat.factory('connection', }) ).then(function(i) { handlers.handleConfValue(i); + if (callback !== undefined) { + callback(); + } }); }; From ac2966ff0bd00c86c03630abec986a89b5b03c32 Mon Sep 17 00:00:00 2001 From: Patrick Melanson Date: Mon, 18 Jul 2016 23:00:11 -0400 Subject: [PATCH 2/3] Base our time format off of weechat's config --- js/connection.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ js/models.js | 19 +------------- 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/js/connection.js b/js/connection.js index 65c9afc..00e4b6d 100644 --- a/js/connection.js +++ b/js/connection.js @@ -77,6 +77,64 @@ weechat.factory('connection', ); }; + var _parseWeechatTimeFormat = function() { + // Fetch the buffer time format from weechat + var timeFormat = models.wconfig['weechat.look.buffer_time_format']; + + // Weechat uses strftime, with time specifiers such as %I:%M:%S for 12h time + // The time formatter we use, AngularJS' date filter, uses a different format + // Where %I:%M:%S would be represented as hh:mm:ss + // Here, we detect what format the user has set in Weechat and slot it into + // one of four formats, (short|long) (12|24)-hour time + var angularFormat = ""; + + var timeDelimiter = "':'"; + + var left12 = "hh" + timeDelimiter + "mm"; + var right12 = "' 'a"; + + var short12 = left12 + right12; + var long12 = left12 + timeDelimiter + "ss" + right12; + + var short24 = "HH" + timeDelimiter + "mm"; + var long24 = short24 + timeDelimiter + "ss"; + + if (timeFormat.indexOf("%H") > -1 || + timeFormat.indexOf("%k") > -1) { + // 24h time detected + if (timeFormat.indexOf("%S") > -1) { + // show seconds + angularFormat = long24; + } else { + // don't show seconds + angularFormat = short24; + } + } else if (timeFormat.indexOf("%I") > -1 || + timeFormat.indexOf("%l") > -1 || + timeFormat.indexOf("%p") > -1 || + timeFormat.indexOf("%P") > -1) { + // 12h time detected + if (timeFormat.indexOf("%S") > -1) { + // show seconds + angularFormat = long12; + } else { + // don't show seconds + angularFormat = short12; + } + } else if (timeFormat.indexOf("%r") > -1) { + // strftime doesn't have an equivalent for short12??? + angularFormat = long12; + } else if (timeFormat.indexOf("%T") > -1) { + angularFormat = long24; + } else if (timeFormat.indexOf("%R") > -1) { + angularFormat = short24; + } else { + angularFormat = short24; + } + + $rootScope.angularTimeFormat = angularFormat; + }; + // First command asks for the password and issues // a version command. If it fails, it means the we @@ -98,6 +156,13 @@ weechat.factory('connection', } }); + // Fetch weechat time format for displaying timestamps + fetchConfValue('weechat.look.buffer_time_format', + function() { + _parseWeechatTimeFormat(); + }); + // Will set models.wconfig['weechat.look.buffer_time_format'] + _requestSync(); $log.info("Connected to relay"); $rootScope.connected = true; diff --git a/js/models.js b/js/models.js index afd029f..a485708 100644 --- a/js/models.js +++ b/js/models.js @@ -347,24 +347,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) var buffer = message.buffer; var date = message.date; var shortTime = $filter('date')(date, 'HH:mm'); - var formattedTime = ""; - - if ($rootScope.supports_formatting_date) { - formattedTime = date.toLocaleTimeString([], {hour: "2-digit", - minute: "2-digit", - second: "2-digit"}); - } else { - formattedTime = $filter('date')(date, 'HH:mm:ss'); - } - - formattedTime = formattedTime.replace(/ /g, " "); - // If in 12h time the hour field has only one number, zero pad it - formattedTime = formattedTime.replace(/^(\d)(:|\.)/, '0$1$2'); - // Wrap the first time separator in a span - formattedTime = formattedTime.replace(/(:|\.)/, '$1'); - // Wrap the second time separator and seconds field in another span - // so that we can easily hide seconds using a CSS selector - formattedTime = formattedTime.replace(/(\d\d)(:|\.)(\d\d)/, '$1$2$3'); + var formattedTime = $filter('date')(date, $rootScope.angularTimeFormat); var prefix = parseRichText(message.prefix); var tags_array = message.tags_array; From ce7715c7947d5681c454858bc2453d738bff3e40 Mon Sep 17 00:00:00 2001 From: Patrick Melanson Date: Wed, 20 Jul 2016 11:28:08 -0400 Subject: [PATCH 3/3] Removed show timestamp [seconds] settings Functionality is now replaced by changing weechat's buffer_time_format. e.g. 24h time: /set weechat.look.buffer_time_format %H:%M Supported time formats are 12h and 24h, with seconds or no seconds. --- css/glowingbear.css | 8 -------- index.html | 26 ++------------------------ js/glowingbear.js | 2 -- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 235f292..fd021fa 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -430,14 +430,6 @@ div.colourbox { } -table.notimestamp td.time { - display: none !important; -} - -table.notimestampseconds td.time span.seconds { - display: none !important; -} - #sidebar .showquickkeys .buffer .buffer-quick-key { transition: all ease-in-out 0.5s; -webkit-transition: all ease-in-out 0.5s; diff --git a/index.html b/index.html index 3453a1a..ca339f2 100644 --- a/index.html +++ b/index.html @@ -276,7 +276,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel - +
@@ -289,7 +289,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel
- + <>