Fix multi-page for tags and feed
} else {
$('older_link').hide();
}
+
+ document.body.scrollTo();
}
Pager.prototype.showPageAt = function(r) {
- if (this.itemCache[r] && this.itemCache[r - 9]) {
+ var end = (r - 9 > 0 ? r - 9 : 0);
+ if (this.itemCache[r] && this.itemCache[end]) {
this.pageStart = r;
this.displayItems();
} else {
});
this.addItems(j);
this.pageStart = j.length - 1;
+ this.itemCount = j.length;
}
this.displayItems();
}.bind(this),
// Pager for browsing subscription feeds
function Feed() {
this.initPager();
+ this.username = loginStatus.username;
this.baseFrag = '/feed';
new Ajax.Request(baseURL + '/feed', {
});
this.addItems(response);
this.pageStart = response.length - 1;
+ this.itemCount = response.length;
}
this.displayItems();
}.bind(this),
j.tags.each(function(v) {
var a = new Element('a', {href: '/#/tag/' + v});
a.insert('#' + v);
- a.onclick = qlink;
+ a.onclick = "return qlink()";
a.className = 'ref';
$('latest-tags').insert(a);
$('latest-tags').appendChild(document.createTextNode(' '));
if (m = location.search.match(/^\?post\/([^/]+)\/(.+)/)) {
$('post').show();
$('post.content').value = '[' + decodeURIComponent(m[1]).replace(']','').replace('[','') + '](' + decodeURIComponent(m[2]) + ')';
- } else if (m = location.hash.match(/^#\/(ref|tag)\/([A-Za-z0-9_-]+)$/)) {
- currentPager = new Tag(m[1], m[2]);
+ } else if (m = location.hash.match(/^#\/(ref|tag)\/([A-Za-z0-9_-]+)(?:\/p(\d+))?$/)) {
+ if (!currentPager || currentPager.type != m[1] || currentPager.tag != m[2])
+ currentPager = new Tag(m[1], m[2]);
currentPager.show();
- } else if (m = location.hash.match(/^#\/feed/)) {
+
+ if (m[3]) {
+ var r = parseInt(m[3]);
+ currentPager.showPageAt(r);
+ }
+ } else if (m = location.hash.match(/^#\/feed(?:\/p(\d+))?$/)) {
if (loginStatus.loggedIn) {
- currentPager = new Feed();
+ if (currentPager && currentPager.username != loginStatus.username)
+ currentPager = new Feed();
currentPager.show();
+ if (m[3]) {
+ var r = parseInt(m[3]);
+ currentPager.showPageAt(r);
+ }
} else {
location.href = baseURL;
}