-var _feed_cur_page = 0;
+//var _feed_cur_page = 0;
var _infscroll_disable = 0;
var _infscroll_request_sent = 0;
var _search_query = false;
return false;
}
-function viewNextFeedPage() {
+function loadMoreHeadlines() {
try {
- //if (!getActiveFeedId()) return;
-
- console.log("viewNextFeedPage: calling viewfeed(), p: " + parseInt(_feed_cur_page+1));
+ var offset = 0;
+
+ var view_mode = document.forms["main_toolbar_form"].view_mode.value;
+ var num_unread = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
+ var num_all = $$("#headlines-frame > div[id*=RROW]").length;
+
+ // TODO implement marked & published
+
+ if (view_mode == "marked") {
+ console.warn("loadMoreHeadlines: marked is not implemented, falling back.");
+ offset = num_all;
+ } else if (view_mode == "published") {
+ console.warn("loadMoreHeadlines: published is not implemented, falling back.");
+ offset = num_all;
+ } else if (view_mode == "unread") {
+ offset = num_unread;
+ } else if (view_mode == "adaptive") {
+ if (num_unread > 0)
+ offset = num_unread;
+ else
+ offset = num_all;
+ } else {
+ offset = num_all;
+ }
- viewfeed(getActiveFeedId(), '', activeFeedIsCat(), parseInt(_feed_cur_page+1));
+ viewfeed(getActiveFeedId(), '', activeFeedIsCat(), offset);
} catch (e) {
exception_error("viewNextFeedPage", e);
try {
if (is_cat == undefined) is_cat = false;
if (subop == undefined) subop = '';
-
-// if (!offset) page_offset = 0;
+ if (offset == undefined) offset = 0;
last_requested_article = 0;
- //counters_last_request = 0;
if (feed == getActiveFeedId()) {
cache_invalidate("F:" + feed);
}
-/* if (getInitParam("theme") == "" || getInitParam("theme") == "compact") {
- if (getInitParam("hide_feedlist") == 1) {
- Element.hide("feeds-holder");
- }
- } */
-
dijit.byId("content-tabs").selectChild(
dijit.byId("content-tabs").getChildren()[0]);
var force_nocache = false;
- var page_offset = 0;
-
- if (offset > 0) {
- page_offset = offset;
- } else {
- page_offset = 0;
- _feed_cur_page = 0;
- _infscroll_disable = 0;
- }
-
- if (getActiveFeedId() != feed) {
- _feed_cur_page = 0;
+ if (getActiveFeedId() != feed || offset == 0) {
active_post_id = 0;
_infscroll_disable = 0;
}
- if (page_offset != 0 && !subop) {
+ if (offset != 0 && !subop) {
var date = new Date();
var timestamp = Math.round(date.getTime() / 1000);
- console.log(_infscroll_request_sent + " : " + timestamp);
-
if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) {
- console.log("infscroll request in progress, aborting");
+ //console.log("infscroll request in progress, aborting");
return;
}
_search_query = false;
}
-// console.log("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
-
if (subop == "MarkAllRead") {
var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
query = query + "&cat=1";
}
- if (page_offset != 0) {
- query = query + "&skip=" + page_offset;
+ if (offset != 0) {
+ query = query + "&skip=" + offset;
// to prevent duplicate feed titles when showing grouped vfeeds
if (vgroup_last_feed) {
console.log(query);
-/* var unread_ctr = -1;
-
- if (!is_cat) unread_ctr = getFeedUnread(feed);
-
- var cache_check = false;
-
- if (unread_ctr != -1 && !page_offset && !force_nocache && !subop) {
-
- var cache_prefix = "";
-
- if (is_cat) {
- cache_prefix = "C:";
- } else {
- cache_prefix = "F:";
- }
-
- cache_check = cache_check_param(cache_prefix + feed, unread_ctr);
- console.log("headline cache check: " + cache_check);
- }
-
- if (cache_check) {
-
- setActiveFeedId(feed, is_cat);
-
- $("headlines-frame").innerHTML = cache_find_param(cache_prefix + feed,
- unread_ctr);
-
- request_counters();
- remove_splash();
-
- } else { */
-
- if (!is_cat) {
- if (!setFeedExpandoIcon(feed, is_cat, 'images/indicator_white.gif'))
- notify_progress("Loading, please wait...", true);
- } else {
+ if (!is_cat) {
+ if (!setFeedExpandoIcon(feed, is_cat, 'images/indicator_white.gif'))
notify_progress("Loading, please wait...", true);
- }
+ } else {
+ notify_progress("Loading, please wait...", true);
+ }
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
- headlines_callback2(transport, page_offset);
- } });
-// }
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
+ headlines_callback2(transport, offset);
+ } });
} catch (e) {
exception_error("viewfeed", e);
$topmost_article_ids = array();
- if (!$offset) {
- $offset = 0;
- }
-
+ if (!$offset) $offset = 0;
if ($subop == "undefined") $subop = "";
$subop_split = explode(":", $subop);
$match_on = "both";
}
- $real_offset = $offset * $limit;
+ //$real_offset = $offset * $limit;
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
$qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view,
- $search, $search_mode, $match_on, $override_order, $real_offset);
+ $search, $search_mode, $match_on, $override_order, $offset);
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
if (db_num_rows($result) > 0) {
- $lnum = $limit*$offset;
+ $lnum = $offset+1;
$num_unread = 0;
$cur_feed_title = '';
}
}
-# if (!$offset) {
-# if ($headlines_count > 0) print "</div>";
-# print "</div>";
-# }
-
- #print "]]></content>";
-
return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
$vgroup_last_feed, $reply['content'], $reply['toolbar']);
}
var catchup_id_batch = [];
var catchup_timeout_id = false;
-function headlines_callback2(transport, feed_cur_page) {
+function headlines_callback2(transport, offset) {
try {
handle_rpc_json(transport);
loading_set_progress(25);
- console.log("headlines_callback2 [page=" + feed_cur_page + "]");
+ console.log("headlines_callback2 [offset=" + offset + "]");
var is_cat = false;
var feed_id = false;
update_btn.disabled = !(feed_id >= 0 && !is_cat);
try {
- if (feed_cur_page == 0) {
+ if (offset == 0) {
$("headlines-frame").scrollTop = 0;
}
} catch (e) { };
var articles = reply['articles'];
var runtime_info = reply['runtime-info'];
- if (feed_cur_page == 0) {
+ if (offset == 0) {
dijit.byId("headlines-frame").attr('content',
reply['headlines']['content']);
var hsp = $("headlines-spacer");
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
- if (!_infscroll_disable)
+/* if (!_infscroll_disable)
hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
- __("Loading, please wait...");
+ __("Loading, please wait..."); */
dijit.byId('headlines-frame').domNode.appendChild(hsp);
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
- if (!_infscroll_disable)
+/* if (!_infscroll_disable)
hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
- __("Loading, please wait...");
+ __("Loading, please wait..."); */
+
+ fixHeadlinesOrder(getLoadedArticleIds());
c.domNode.appendChild(hsp);
__('Could not update headlines (invalid object received)') + "</div>");
}
- _feed_cur_page = feed_cur_page;
+ //_feed_cur_page = feed_cur_page;
_infscroll_request_sent = 0;
notify("");
var id = articles[i]['id'];
if (!cache_check(id)) {
cache_inject(id, articles[i]['content']);
- console.log("preloaded article: " + id);
+ //console.log("preloaded article: " + id);
}
}
} });
if (post_under_pointer == id && !cache_check(id)) {
- console.log("trying to preload article " + id);
+ //console.log("trying to preload article " + id);
var neighbor_ids = getRelativePostIds(id, 1);
if (hsp && (e.scrollTop + e.offsetHeight > hsp.offsetTop) ||
e.scrollTop + e.offsetHeight > e.scrollHeight - 100) {
- viewNextFeedPage();
+ hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
+ __("Loading, please wait...");
+
+ loadMoreHeadlines();
+
+ //viewNextFeedPage();
}
} else {
if (hsp) hsp.innerHTML = "";