Sourcecode in Site/renderFunctions.js:
1: function renderStorylist(day) {
2: var size = this.size();
3: var idx = 0;
4:
5: // if no day is specified, start with today. we may need
6: // to search for today's entries (or the latest entry
7: // before today) because there may be stories posted for
8: // future days. (HW)
9: var startdayString = day;
10: if (!startdayString)
11: startdayString = formatTimestamp(new Date(), "yyyyMMdd");
12:
13: var startday = this.get(startdayString);
14: if (startday && startday.size()>0) {
15: idx = this.contains(startday);
16: } else {
17: // loop through days until we find a day less or equal than
18: // the one we're looking for.
19: for (var i=0; i<size; i++) {
20: if (startdayString >= this.get(i).groupname) {
21: this.get(i).prefetchChildren();
22: idx = i;
23: break;
24: }
25: }
26: }
27: var days = this.preferences.getProperty("days") ? this.preferences.getProperty("days") : 2;
28: days = Math.min (days, 14); // render 14 days max
29: this.prefetchChildren(idx, days);
30:
31: // only display "newer stories" if we are actually browsing the archive,
32: // and the day parameter has been explicitly specified,
33: // i.e. suppress the link if we are on the home page and there are
34: // stories on future days. (HW)
35: if (idx > 0 && day) {
36: var sp = new Object();
37: var prev = this.get (Math.max(0, idx-days));
38: sp.url = this.href() + "?day=" + prev.groupname;
39: sp.text = getMessage("Story.newerStories");
40: res.data.prevpage = renderSkinAsString("prevpagelink", sp);
41: }
42: days = Math.min(idx + days++, this.size());
43: res.push();
44: while (idx < days) {
45: var day = this.get(idx++);
46: day.get(0).renderSkin("dayheader");
47: for (var i=0;i<day.size();i++)
48: day.get(i).renderSkin("preview");
49: }
50: res.data.storylist = res.pop();
51: if (idx < size) {
52: var sp = new Object();
53: var next = this.get (idx);
54: sp.url = this.href() + "?day=" + next.groupname;
55: sp.text = getMessage("Story.olderStories");
56: res.data.nextpage = renderSkinAsString("nextpagelink", sp);
57: }
58: return;
59: }
|