fix some issues in infinite scrolling
This commit is contained in:
parent
4ab4d3640b
commit
29dfb258c9
4 changed files with 40 additions and 36 deletions
|
@ -221,11 +221,16 @@
|
|||
|
||||
print "<headlines id=\"$feed\"><![CDATA[";
|
||||
|
||||
$topmost_article_ids = outputHeadlinesList($link, $feed, $subop,
|
||||
$ret = outputHeadlinesList($link, $feed, $subop,
|
||||
$view_mode, $limit, $cat_view, $next_unread_feed, $offset);
|
||||
|
||||
$topmost_article_ids = $ret[0];
|
||||
$headlines_count = $ret[1];
|
||||
|
||||
print "]]></headlines>";
|
||||
|
||||
print "<headlines-count value=\"$headlines_count\"/>";
|
||||
|
||||
if ($_GET["debug"]) $timing_info = print_checkpoint("10", $timing_info);
|
||||
|
||||
if (is_array($topmost_article_ids) && !get_pref($link, 'COMBINED_DISPLAY_MODE')) {
|
||||
|
|
31
feedlist.js
31
feedlist.js
|
@ -1,6 +1,7 @@
|
|||
//var xmlhttp = Ajax.getTransport();
|
||||
|
||||
var _feed_cur_page = 0;
|
||||
var _infscroll_disable = 0;
|
||||
|
||||
function viewCategory(cat) {
|
||||
active_feed_is_cat = true;
|
||||
|
@ -25,35 +26,14 @@ function feedlist_callback2(transport) {
|
|||
}
|
||||
}
|
||||
|
||||
var page_offset = 0;
|
||||
|
||||
function viewFeedGoPage(i) {
|
||||
try {
|
||||
if (!getActiveFeedId()) return;
|
||||
|
||||
if (i != 0) {
|
||||
page_offset = page_offset + i;
|
||||
} else {
|
||||
page_offset = 0;
|
||||
}
|
||||
|
||||
if (page_offset < 0) page_offset = 0;
|
||||
viewfeed(getActiveFeedId(), undefined, undefined, undefined,
|
||||
undefined, page_offset);
|
||||
} catch (e) {
|
||||
exception_error(e, "viewFeedGoPage");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function viewNextFeedPage() {
|
||||
try {
|
||||
if (!getActiveFeedId()) return;
|
||||
|
||||
_feed_cur_page++;
|
||||
notify_progress("Loading, please wait...");
|
||||
|
||||
viewfeed(getActiveFeedId(), undefined, undefined, undefined,
|
||||
undefined, _feed_cur_page);
|
||||
undefined, _feed_cur_page+1);
|
||||
|
||||
} catch (e) {
|
||||
exception_error(e, "viewFeedGoPage");
|
||||
|
@ -72,11 +52,13 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
|
|||
} else {
|
||||
page_offset = 0;
|
||||
_feed_cur_page = 0;
|
||||
_infscroll_disable = 0;
|
||||
}
|
||||
|
||||
if (getActiveFeedId() != feed) {
|
||||
_feed_cur_page = 0;
|
||||
active_post_id = 0;
|
||||
_infscroll_disable = 0;
|
||||
}
|
||||
|
||||
enableHotkeys();
|
||||
|
@ -187,8 +169,9 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
|
|||
} */
|
||||
|
||||
new Ajax.Request(query, {
|
||||
asynchronous: page_offset == 0,
|
||||
onComplete: function(transport) {
|
||||
headlines_callback2(transport, feed, is_cat, _feed_cur_page);
|
||||
headlines_callback2(transport, feed, is_cat, page_offset);
|
||||
} });
|
||||
|
||||
} catch (e) {
|
||||
|
|
|
@ -4216,6 +4216,8 @@
|
|||
print "<div id=\"headlinesInnerContainer\" onscroll=\"headlines_scroll_handler()\">";
|
||||
}
|
||||
|
||||
$headlines_count = db_num_rows($result);
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
|
||||
# print "\{$offset}";
|
||||
|
@ -4464,7 +4466,7 @@
|
|||
print "</div>";
|
||||
}
|
||||
|
||||
return $topmost_article_ids;
|
||||
return array($topmost_article_ids, $headlines_count);
|
||||
}
|
||||
|
||||
// from here: http://www.roscripts.com/Create_tag_cloud-71.html
|
||||
|
|
34
viewfeed.js
34
viewfeed.js
|
@ -46,7 +46,8 @@ function catchup_callback2(transport, callback) {
|
|||
}
|
||||
|
||||
function headlines_callback2(transport, active_feed_id, active_feed_is_cat, feed_cur_page) {
|
||||
debug("headlines_callback2");
|
||||
debug("headlines_callback2 [page=" + feed_cur_page + "]");
|
||||
|
||||
var f = document.getElementById("headlines-frame");
|
||||
try {
|
||||
if (feed_cur_page == 0) {
|
||||
|
@ -57,6 +58,12 @@ function headlines_callback2(transport, active_feed_id, active_feed_is_cat, feed
|
|||
|
||||
if (transport.responseXML) {
|
||||
var headlines = transport.responseXML.getElementsByTagName("headlines")[0];
|
||||
var headlines_count_obj = transport.responseXML.getElementsByTagName("headlines-count")[0];
|
||||
|
||||
var headlines_count = headlines_count_obj.getAttribute("value");
|
||||
|
||||
if (headlines_count == 0) _infscroll_disable = 1;
|
||||
|
||||
var counters = transport.responseXML.getElementsByTagName("counters")[0];
|
||||
var articles = transport.responseXML.getElementsByTagName("article");
|
||||
var runtime_info = transport.responseXML.getElementsByTagName("runtime-info");
|
||||
|
@ -71,15 +78,19 @@ function headlines_callback2(transport, active_feed_id, active_feed_is_cat, feed
|
|||
}
|
||||
} else {
|
||||
if (headlines) {
|
||||
debug("adding some more headlines...");
|
||||
if (headlines_count > 0) {
|
||||
debug("adding some more headlines...");
|
||||
|
||||
var c = document.getElementById("headlinesList");
|
||||
var c = document.getElementById("headlinesList");
|
||||
|
||||
if (!c) {
|
||||
c = document.getElementById("headlinesInnerContainer");
|
||||
}
|
||||
|
||||
if (!c) {
|
||||
c = document.getElementById("headlinesInnerContainer");
|
||||
c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
|
||||
} else {
|
||||
debug("no new headlines received");
|
||||
}
|
||||
|
||||
c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
|
||||
} else {
|
||||
debug("headlines_callback: returned no data");
|
||||
notify_error("Error while trying to load more headlines");
|
||||
|
@ -140,6 +151,8 @@ function headlines_callback2(transport, active_feed_id, active_feed_is_cat, feed
|
|||
} catch (e) { }
|
||||
}
|
||||
|
||||
_feed_cur_page = feed_cur_page;
|
||||
|
||||
notify("");
|
||||
}
|
||||
|
||||
|
@ -1244,9 +1257,10 @@ function headlines_scroll_handler() {
|
|||
var e = document.getElementById("headlinesInnerContainer");
|
||||
|
||||
if (e.scrollTop + e.offsetHeight > e.scrollHeight - 300) {
|
||||
debug("more cowbell!");
|
||||
|
||||
viewNextFeedPage();
|
||||
if (!_infscroll_disable) {
|
||||
debug("more cowbell!");
|
||||
viewNextFeedPage();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in a new issue