From aa8d89d14be75c22b8f95dc9f8c1db6a8f061bb9 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 5 Feb 2017 22:43:21 +1300 Subject: [PATCH] client: display unread message count in the title --- client/dcwebui.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/dcwebui.js b/client/dcwebui.js index e31a702..b86246b 100644 --- a/client/dcwebui.js +++ b/client/dcwebui.js @@ -467,11 +467,16 @@ var tab_set = function(tab) { } } + if (tab == "tab-main" && pagevis_currently_visible) { + mainchat_unread_count = 0; + } + updateTitle(); write(tab).scroll(); $("#chatbox").focus(); last_tab = tab; + }; var tab_new = function(id, name) { @@ -768,7 +773,7 @@ var updateTitle = function() { var prefix = ""; var unrTabs = $(".unread"); if (unrTabs.length === 1 && unrTabs[0].getAttribute('data-tab') == "tab-main") { - prefix = "[NEW] " + prefix = "[" + mainchat_unread_count + " NEW] " } else if (unrTabs.length > 0) { prefix = "[NEW PM] " } @@ -803,6 +808,8 @@ var timestamp_formats = [ "H:i", "H:i:s", "Y-m-d H:i:s" ]; var timestamp_names = [ "Minutes", "Seconds", "Full" ]; var timestamp_format_index = 0; +var mainchat_unread_count = 0; + var timestamp_display = function() { return "Timestamp format: " + timestamp_names[timestamp_format_index]; }; @@ -1054,6 +1061,8 @@ window.onload = function() { if (! tab_is_visible("tab-main")) { tab_mark_unread("tab-main"); + mainchat_unread_count += 1; + updateTitle(); } }); sock.on('priv', function(data) {