summaryrefslogtreecommitdiff
path: root/program/js/app.js
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2008-08-29 14:10:18 +0000
committerthomascube <thomas@roundcube.net>2008-08-29 14:10:18 +0000
commit85360dc8df13c9641301f0b40b1ecf00d3c1e966 (patch)
treef804eb7eeaf9eae0f44598f8432d797947e5ef9f /program/js/app.js
parent25f80d62d18cab40b74ac4a55628bb6d8926b4ec (diff)
Fix unread count display: save counts in list, use the right vars
Diffstat (limited to 'program/js/app.js')
-rw-r--r--program/js/app.js28
1 files changed, 13 insertions, 15 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 4ed67cbc0..6b475ce35 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -230,6 +230,7 @@ function rcube_webmail()
// get unread count for each mailbox
if (this.gui_objects.mailboxlist)
{
+ this.env.unread_counts = {};
this.gui_objects.folderlist = this.gui_objects.mailboxlist;
this.http_request('getunread', '');
}
@@ -3484,22 +3485,18 @@ function rcube_webmail()
if (!this.gui_objects.mailboxlist)
return false;
- var reg, text_obj, item;
- if (item = this.get_folder_li(mbox))
- {
- item.setAttribute('count', count);
- this.set_unread_count_display(mbox, set_title);
- }
+ this.env.unread_counts[mbox] = count;
+ this.set_unread_count_display(mbox, set_title);
}
// update the mailbox count display
this.set_unread_count_display = function(mbox, set_title)
{
- var reg, text_obj, item, mycount, childcount, div, children;
+ var reg, text_obj, item, mycount, childcount, div;
if (item = this.get_folder_li(mbox))
{
- mycount = parseInt(item.getAttribute('count') ? item.getAttribute('count') : 0);
+ mycount = this.env.unread_counts[mbox];
text_obj = item.getElementsByTagName('a')[0];
reg = /\s+\([0-9]+\)$/i;
@@ -3508,9 +3505,10 @@ function rcube_webmail()
div.className.match(/collapsed/))
{
// add children's counters
- children = item.getElementsByTagName('li');
- for (var i=0; i<children.length; i++)
- childcount = childcount+parseInt(children[i].getAttribute('count') ? children[i].getAttribute('count') : 0);
+ for (var k in this.env.unread_counts)
+ if (k.indexOf(mbox) == 0) {
+ childcount += this.env.unread_counts[k];
+ }
}
if (mycount && text_obj.innerHTML.match(reg))
@@ -3536,10 +3534,10 @@ function rcube_webmail()
var doc_title = String(document.title);
var new_title = "";
- if (count && doc_title.match(reg))
- new_title = doc_title.replace(reg, '('+count+') ');
- else if (count)
- new_title = '('+count+') '+doc_title;
+ if (mycount && doc_title.match(reg))
+ new_title = doc_title.replace(reg, '('+mycount+') ');
+ else if (mycount)
+ new_title = '('+mycount+') '+doc_title;
else
new_title = doc_title.replace(reg, '');