From: Andrew Dolgov Date: Thu, 9 Aug 2007 07:36:04 +0000 (+0100) Subject: infinite scrolling X-Git-Tag: 1.2.14~125 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ac541432000c24fee20cf0e0ce0881aa6437455a;p=tt-rss.git infinite scrolling --- diff --git a/feedlist.js b/feedlist.js index ac852e9e..66b040f9 100644 --- a/feedlist.js +++ b/feedlist.js @@ -1,5 +1,7 @@ //var xmlhttp = Ajax.getTransport(); +var feed_cur_page = 0; + function viewCategory(cat) { active_feed_is_cat = true; viewfeed(cat, '', true); @@ -35,13 +37,35 @@ function viewFeedGoPage(i) { } } + +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(); diff --git a/functions.php b/functions.php index 3bf2a0b7..7ca93956 100644 --- a/functions.php +++ b/functions.php @@ -3693,7 +3693,9 @@ $topmost_article_ids = array(); - if (!$offset) $offset = 0; + if (!$offset) { + $offset = 0; + } if ($subop == "undefined") $subop = ""; @@ -3777,24 +3779,26 @@ /// STOP ////////////////////////////////////////////////////////////////////////////////// - print "
"; + if (!$offset) { + print "
"; - if (!$result) { - print "
".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."
"; - return; - } + if (!$result) { + print "
".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."
"; + 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 "
"; + print "
"; + } if (db_num_rows($result) > 0) { # print "\{$offset}"; - if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { + if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) { print ""; } @@ -3975,7 +3979,7 @@ ++$lnum; } - if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { + if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) { print "
"; } @@ -3984,12 +3988,13 @@ } else { - print "
".__('No articles found.')."
"; + if (!$offset) print "
".__('No articles found.')."
"; } - print "
"; - - print "
"; + if (!$offset) { + print "
"; + print "
"; + } return $topmost_article_ids; } diff --git a/viewfeed.js b/viewfeed.js index 1a3d775f..e464f219 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -38,7 +38,10 @@ function headlines_callback() { 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) { @@ -47,11 +50,29 @@ function headlines_callback() { 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 = "
" + __('Could not update headlines (missing XML data)') + "
"; + + } } else { - debug("headlines_callback: returned no data"); - f.innerHTML = "
" + __('Could not update headlines (missing XML data)') + "
"; + 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"); + } } @@ -103,6 +124,8 @@ function headlines_callback() { try { document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll; _tag_cdm_scroll = false; + debug("resetting headlinesInner scrollTop"); + } catch (e) { } } @@ -937,3 +960,19 @@ function cdmMouseIn(elem) { 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); + } +}