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')) {
//var xmlhttp = Ajax.getTransport();
var _feed_cur_page = 0;
+var _infscroll_disable = 0;
function viewCategory(cat) {
active_feed_is_cat = true;
}
}
-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");
} 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();
} */
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) {
print "<div id=\"headlinesInnerContainer\" onscroll=\"headlines_scroll_handler()\">";
}
+ $headlines_count = db_num_rows($result);
+
if (db_num_rows($result) > 0) {
# print "\{$offset}";
print "</div>";
}
- return $topmost_article_ids;
+ return array($topmost_article_ids, $headlines_count);
}
// from here: http://www.roscripts.com/Create_tag_cloud-71.html
}
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) {
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");
}
} 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");
} catch (e) { }
}
+ _feed_cur_page = feed_cur_page;
+
notify("");
}
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) {