r9895 - apps/gobi/trunk/code/Updates

[email protected] Tue, 15 Sep 2009 00:19:22 +0200 (CEST)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090914221922.8E6E73D0E3@mia>
Author: hannes
Date: 2009-09-15 00:19:22 +0200 (Tue, 15 Sep 2009)
New Revision: 9895

Modified:
   apps/gobi/trunk/code/Updates/Updates.js
Log:
Make updates page paginate per month

Details at http://dev.helma.org/trac/helma/changeset/9895

Modified: apps/gobi/trunk/code/Updates/Updates.js
===================================================================
--- apps/gobi/trunk/code/Updates/Updates.js	2009-09-14 22:04:48 UTC (rev 9894)
+++ apps/gobi/trunk/code/Updates/Updates.js	2009-09-14 22:19:22 UTC (rev 9895)
@@ -73,30 +73,24 @@
         timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT);
     }
     var table = new Html.TableWriter(4, tableStyle);
-    var i, date, lastDay, month, first = true;
+    var i, date, month, lastDay, first = true;
+    var prevMonth, nextMonth;
     for (i = 0; i < items.length; i++) {
         var group = items[i];
         var day = group.groupname.substring(7, 17);
         if (!pattern.test(day)) {
-            lastDay = day;
             if (!first) {
+                prevMonth = day.substring(0, 7);
                 break;
             } else {
+                nextMonth = day.substring(0, 7);
                 continue;
             }
         }
         if (first) {
             month = day.substring(0, 7);
             first = false;
-            if (i > 0) {
-                Html.p({style: "text-align: right;"},
-                    Html.A({href: this.href() + "?day=" + lastDay}, "later updates"));
-            }
         }
-        if (day.indexOf(month) != 0) {
-            lastDay = day;
-            break;
-        }
         if (day != lastDay) {
             date = day.toDate("yyyy.MM.dd");
             lastDay = day;
@@ -147,10 +141,14 @@
             }
         }
     }
+    if (nextMonth) {
+        Html.p({style: "text-align: right;"},
+                Html.A({href: this.href() + "?month=" + nextMonth}, "later updates"));
+    }
     table.close();
-    if (i < items.length) {
+    if (prevMonth) {
         Html.p({style: "text-align: right;"},
-                Html.A({href: this.href() + "?day=" + lastDay}, "earlier updates"));
+                Html.A({href: this.href() + "?month=" + prevMonth}, "earlier updates"));
     }
 }