Permalink
Browse files

Added counts to the list.

Closes #3
  • Loading branch information...
1 parent d0a3c48 commit 260c198604bc0b64377a031f792f9a3e70465d70 @dustin committed Sep 1, 2011
Showing with 26 additions and 6 deletions.
  1. +3 −3 _attachments/index.html
  2. +14 −0 _attachments/js/readme.js
  3. +3 −3 templates/tail.html
  4. +5 −0 views/counts/map.js
  5. +1 −0 views/counts/reduce.js
View
6 _attachments/index.html
@@ -11,9 +11,9 @@
<div id="sidebar">
<ul class="statelist">
- <li><a href="#" title="unread">Unread</a></li>
- <li><a href="#" title="important">Important</a></li>
- <li><a href="#" title="done">Done</a></li>
+ <li><a href="#" title="unread">Unread</a><span id="unread-count"/></li>
+ <li><a href="#" title="important">Important</a><span id="important-count"</span></li>
+ <li><a href="#" title="done">Done</a><span id="done-count"/></li>
</ul>
</div>
</body>
View
14 _attachments/js/readme.js
@@ -43,6 +43,18 @@ function myPretty(ts) {
date.toString();
}
+function rm_updateCounts(app) {
+ app.db.view('app/counts', {
+ group: true,
+ reduce: true,
+ success: function(d) {
+ d.rows.forEach(function(r) {
+ $('#' + r.key + '-count').text(" (" + r.value + ")");
+ });
+ }
+ });
+}
+
function rm_refreshTimestamps() {
rm_updateTimestamps();
setTimeout(rm_refreshTimestamps, 60000);
@@ -88,4 +100,6 @@ function rm_init_list_links(app) {
include_docs: true,
limit: 50}));
});
+
+ rm_updateCounts(app);
}
View
6 templates/tail.html
@@ -2,9 +2,9 @@
<div id="sidebar">
<ul class="statelist">
- <li><a href="#" title="unread">Unread</a></li>
- <li><a href="#" title="important">Important</a></li>
- <li><a href="#" title="done">Done</a></li>
+ <li><a href="#" title="unread">Unread</a><span id="unread-count"/></li>
+ <li><a href="#" title="important">Important</a><span id="important-count"</span></li>
+ <li><a href="#" title="done">Done</a><span id="done-count"/></li>
</ul>
</div>
View
5 views/counts/map.js
@@ -0,0 +1,5 @@
+function(doc) {
+ if (doc.rm_state) {
+ emit(doc.rm_state, null);
+ }
+};
View
1 views/counts/reduce.js
@@ -0,0 +1 @@
+_count

0 comments on commit 260c198

Please sign in to comment.