[dw-free] Dynamic inbox count in menu
[commit: http://hg.dwscoalition.org/dw-free/rev/0b282f02da3d]
http://bugs.dwscoalition.org/show_bug.cgi?id=378
Make the menu count for unread inbox items dynamic as well.
Patch by
afuna.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=378
Make the menu count for unread inbox items dynamic as well.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/Logic/MenuNav.pm
- htdocs/js/livejournal.js
-------------------------------------------------------------------------------- diff -r be4f84e0c13a -r 0b282f02da3d cgi-bin/DW/Logic/MenuNav.pm --- a/cgi-bin/DW/Logic/MenuNav.pm Thu Dec 03 04:46:54 2009 +0000 +++ b/cgi-bin/DW/Logic/MenuNav.pm Thu Dec 03 04:54:44 2009 +0000 @@ -182,7 +182,7 @@ sub get_menu_navigation { { url => "$LJ::SITEROOT/inbox/", text => $inbox_count ? "menunav.read.inbox.unread" : "menunav.read.inbox.nounread", - text_opts => { num => $inbox_count }, + text_opts => { num => "<span id='Inbox_Unread_Count_Menu'>$inbox_count</span>" }, display => $loggedin, }, ], diff -r be4f84e0c13a -r 0b282f02da3d htdocs/js/livejournal.js --- a/htdocs/js/livejournal.js Thu Dec 03 04:46:54 2009 +0000 +++ b/htdocs/js/livejournal.js Thu Dec 03 04:54:44 2009 +0000 @@ -69,7 +69,8 @@ LiveJournal.initInboxUpdate = function ( // Don't run if no inbox count var unread = $("Inbox_Unread_Count"); - if (! unread) return; + var unread_menu = $("Inbox_Unread_Count_Menu"); + if (! unread && ! unread_menu) return; // Update every five minutes window.setInterval(LiveJournal.updateInbox, 1000 * 60 * 5); @@ -97,9 +98,13 @@ LiveJournal.gotInboxUpdate = function (r if (! resp || resp.error) return; var unread = $("Inbox_Unread_Count"); - if (! unread) return; + var unread_menu = $("Inbox_Unread_Count_Menu"); + if (! unread && ! unread_menu) return; - unread.innerHTML = resp.unread_count ? " (" + resp.unread_count + ")" : ""; + if ( unread ) + unread.innerHTML = resp.unread_count ? " (" + resp.unread_count + ")" : ""; + if ( unread_menu ) + unread_menu.innerHTML = resp.unread_count ? resp.unread_count : ""; }; // Search for placeholders and initialize them --------------------------------------------------------------------------------