//var xmlhttp = Ajax.getTransport();
+var feed_cur_page = 0;
+
function viewCategory(cat) {
active_feed_is_cat = true;
viewfeed(cat, '', true);
}
}
+
+function viewNextFeedPage() {
+ try {
+ if (!getActiveFeedId()) return;
+
+ feed_cur_page++;
+
+ viewfeed(getActiveFeedId(), undefined, undefined, undefined,
+ undefined, feed_cur_page);
+
+ } catch (e) {
+ exception_error(e, "viewFeedGoPage");
+ }
+}
+
function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
try {
- //if (!offset) page_offset = 0;
+// if (!offset) page_offset = 0;
- if (offset != undefined) {
+ if (offset > 0) {
page_offset = offset;
+ } else {
+ page_offset = 0;
+ feed_cur_page = 0;
+ }
+
+ if (getActiveFeedId() != feed) {
+ feed_cur_page = 0;
}
enableHotkeys();
$topmost_article_ids = array();
- if (!$offset) $offset = 0;
+ if (!$offset) {
+ $offset = 0;
+ }
if ($subop == "undefined") $subop = "";
/// STOP //////////////////////////////////////////////////////////////////////////////////
- print "<div id=\"headlinesContainer\" $rtl_tag>";
+ if (!$offset) {
+ print "<div id=\"headlinesContainer\" $rtl_tag>";
- if (!$result) {
- print "<div align='center'>".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."</div>";
- return;
- }
+ if (!$result) {
+ print "<div align='center'>".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."</div>";
+ return;
+ }
- print_headline_subtoolbar($link, $feed_site_url, $feed_title, false,
- $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode,
- $offset, $limit);
+ print_headline_subtoolbar($link, $feed_site_url, $feed_title, false,
+ $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode,
+ $offset, $limit);
- print "<div id=\"headlinesInnerContainer\">";
+ print "<div id=\"headlinesInnerContainer\" onscroll=\"headlines_scroll_handler()\">";
+ }
if (db_num_rows($result) > 0) {
# print "\{$offset}";
- if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
+ if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) {
print "<table class=\"headlinesList\" id=\"headlinesList\"
cellspacing=\"0\">";
}
++$lnum;
}
- if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
+ if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) {
print "</table>";
}
} else {
- print "<div class='whiteBox'>".__('No articles found.')."</div>";
+ if (!$offset) print "<div class='whiteBox'>".__('No articles found.')."</div>";
}
- print "</div>";
-
- print "</div>";
+ if (!$offset) {
+ print "</div>";
+ print "</div>";
+ }
return $topmost_article_ids;
}
debug("headlines_callback");
var f = document.getElementById("headlines-frame");
try {
- f.scrollTop = 0;
+ if (feed_cur_page == 0) {
+ debug("resetting headlines scrollTop");
+ f.scrollTop = 0;
+ }
} catch (e) { };
if (xmlhttp.responseXML) {
var articles = xmlhttp.responseXML.getElementsByTagName("article");
var runtime_info = xmlhttp.responseXML.getElementsByTagName("runtime-info");
- if (headlines) {
- f.innerHTML = headlines.firstChild.nodeValue;
+ if (feed_cur_page == 0) {
+ if (headlines) {
+ f.innerHTML = headlines.firstChild.nodeValue;
+ } else {
+ debug("headlines_callback: returned no data");
+ f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
+
+ }
} else {
- debug("headlines_callback: returned no data");
- f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
+ if (headlines) {
+ debug("adding some more headlines...");
+
+ var c = document.getElementById("headlinesList");
+
+ if (!c) {
+ c = document.getElementById("headlinesInnerContainer");
+ }
+
+ c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
+ } else {
+ debug("headlines_callback: returned no data");
+ notify_error("Error while trying to load more headlines");
+ }
}
try {
document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll;
_tag_cdm_scroll = false;
+ debug("resetting headlinesInner scrollTop");
+
} catch (e) { }
}
function cdmMouseOut(elem) {
active_post_id = false;
}
+
+function headlines_scroll_handler() {
+ try {
+
+ var e = document.getElementById("headlinesInnerContainer");
+
+ if (e.scrollTop + e.offsetHeight == e.scrollHeight) {
+ debug("more cowbell!");
+
+ viewNextFeedPage();
+ }
+
+ } catch (e) {
+ exception_error("headlines_scroll_handler", e);
+ }
+}