diff --git a/backend.php b/backend.php index 0e4541e74..3783c8226 100644 --- a/backend.php +++ b/backend.php @@ -221,11 +221,16 @@ print ""; + print ""; + if ($_GET["debug"]) $timing_info = print_checkpoint("10", $timing_info); if (is_array($topmost_article_ids) && !get_pref($link, 'COMBINED_DISPLAY_MODE')) { diff --git a/feedlist.js b/feedlist.js index c78a47d5c..70e436897 100644 --- a/feedlist.js +++ b/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) { diff --git a/functions.php b/functions.php index f2fa61b6f..40abd4132 100644 --- a/functions.php +++ b/functions.php @@ -4216,6 +4216,8 @@ print "
"; } + $headlines_count = db_num_rows($result); + if (db_num_rows($result) > 0) { # print "\{$offset}"; @@ -4464,7 +4466,7 @@ print "
"; } - return $topmost_article_ids; + return array($topmost_article_ids, $headlines_count); } // from here: http://www.roscripts.com/Create_tag_cloud-71.html diff --git a/viewfeed.js b/viewfeed.js index 197b7648b..a69c012a2 100644 --- a/viewfeed.js +++ b/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) {