antville/code/Topic/renderFunctions.js

40 lines
No EOL
1.3 KiB
JavaScript

/**
* function renders the list of stories for day-pages
* and assigns the rendered list to res.data.storylist
* scrollnavigation-links to previous and next page(s) are also
* assigned to res.data (res.data.prevpage, res.data.nextpage)
* using this separate renderFunction instead of doing the stuff
* in storylist_macro() was necessary for completely independent
* placement of the prevpage- and nextpage-links
* @param Int Index-position to start with
*/
function renderStorylist(idx) {
var size = this.size();
if (idx < 0 || isNaN (idx)|| idx > size-1)
idx = 0;
var cnt = 0;
var max = Math.min (10, size);
if (idx > 0) {
var sp = new Object();
sp.url = this.href() + "?start=" + Math.max(0, idx-10);
sp.text = "previous topics";
res.data.prevpage = renderSkinAsString("prevpagelink",sp);
}
res.data.storylist = "";
while (cnt < max && idx < size) {
var st = this.get(idx);
if (st.isOnline()) {
res.data.storylist += st.renderSkinAsString("preview");
cnt++;
}
idx++;
}
if (idx < size) {
var sp = new Object();
sp.url = this.href() + "?start=" + idx;
sp.text = "more topics";
res.data.nextpage = renderSkinAsString("nextpagelink",sp);
}
return;
}