async headlines_callback fixes
This commit is contained in:
parent
29dfb258c9
commit
6c3b019894
2 changed files with 124 additions and 117 deletions
27
feedlist.js
27
feedlist.js
|
@ -83,30 +83,18 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
|
||||||
closeInfoBox(true);
|
closeInfoBox(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
|
// debug("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
|
||||||
|
|
||||||
var fe = document.getElementById("FEEDR-" + getActiveFeedId());
|
|
||||||
|
|
||||||
if (fe) {
|
|
||||||
fe.className = fe.className.replace("Selected", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
setActiveFeedId(feed);
|
|
||||||
|
|
||||||
if (is_cat != undefined) {
|
|
||||||
active_feed_is_cat = is_cat;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subop == "MarkAllRead") {
|
if (subop == "MarkAllRead") {
|
||||||
|
|
||||||
var feedlist = document.getElementById('feedList');
|
var feedlist = document.getElementById('feedList');
|
||||||
|
|
||||||
var next_unread_feed = getRelativeFeedId(feedlist,
|
var next_unread_feed = getRelativeFeedId(feedlist,
|
||||||
getActiveFeedId(), "next", true);
|
feed, "next", true);
|
||||||
|
|
||||||
if (!next_unread_feed) {
|
if (!next_unread_feed) {
|
||||||
next_unread_feed = getRelativeFeedId(feedlist,
|
next_unread_feed = getRelativeFeedId(feedlist,
|
||||||
-1, "next", true);
|
-3, "next", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
|
var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
|
||||||
|
@ -117,7 +105,7 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeFeedIsCat()) {
|
if (is_cat) {
|
||||||
query = query + "&cat=1";
|
query = query + "&cat=1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,13 +117,6 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
|
||||||
var timestamp = Math.round(date.getTime() / 1000);
|
var timestamp = Math.round(date.getTime() / 1000);
|
||||||
query = query + "&ts=" + timestamp
|
query = query + "&ts=" + timestamp
|
||||||
|
|
||||||
if (!activeFeedIsCat()) {
|
|
||||||
var feedr = document.getElementById("FEEDR-" + getActiveFeedId());
|
|
||||||
if (feedr && !feedr.className.match("Selected")) {
|
|
||||||
feedr.className = feedr.className + "Selected";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
disableContainerChildren("headlinesToolbar", false);
|
disableContainerChildren("headlinesToolbar", false);
|
||||||
Form.enable("main_toolbar_form");
|
Form.enable("main_toolbar_form");
|
||||||
|
|
||||||
|
|
198
viewfeed.js
198
viewfeed.js
|
@ -45,115 +45,141 @@ function catchup_callback2(transport, callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function headlines_callback2(transport, active_feed_id, active_feed_is_cat, feed_cur_page) {
|
function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) {
|
||||||
debug("headlines_callback2 [page=" + feed_cur_page + "]");
|
|
||||||
|
|
||||||
var f = document.getElementById("headlines-frame");
|
|
||||||
try {
|
try {
|
||||||
if (feed_cur_page == 0) {
|
|
||||||
debug("resetting headlines scrollTop");
|
|
||||||
f.scrollTop = 0;
|
|
||||||
}
|
|
||||||
} catch (e) { };
|
|
||||||
|
|
||||||
if (transport.responseXML) {
|
debug("headlines_callback2 [page=" + feed_cur_page + "]");
|
||||||
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");
|
var feeds = document.getElementById("feedList").getElementsByTagName("LI");
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
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>";
|
|
||||||
|
|
||||||
|
for (var i = 0; i < feeds.length; i++) {
|
||||||
|
if (feeds[i].id && feeds[i].id.match("FEEDR-")) {
|
||||||
|
feeds[i].className = feeds[i].className.replace("Selected", "");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (headlines) {
|
|
||||||
if (headlines_count > 0) {
|
|
||||||
debug("adding some more headlines...");
|
|
||||||
|
|
||||||
var c = document.getElementById("headlinesList");
|
setActiveFeedId(active_feed_id);
|
||||||
|
|
||||||
if (!c) {
|
if (is_cat != undefined) {
|
||||||
c = document.getElementById("headlinesInnerContainer");
|
active_feed_is_cat = is_cat;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
|
if (!is_cat) {
|
||||||
|
var feedr = document.getElementById("FEEDR-" + active_feed_id);
|
||||||
|
if (feedr && !feedr.className.match("Selected")) {
|
||||||
|
feedr.className = feedr.className + "Selected";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var f = document.getElementById("headlines-frame");
|
||||||
|
try {
|
||||||
|
if (feed_cur_page == 0) {
|
||||||
|
debug("resetting headlines scrollTop");
|
||||||
|
f.scrollTop = 0;
|
||||||
|
}
|
||||||
|
} catch (e) { };
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
if (feed_cur_page == 0) {
|
||||||
|
if (headlines) {
|
||||||
|
f.innerHTML = headlines.firstChild.nodeValue;
|
||||||
} else {
|
} else {
|
||||||
debug("no new headlines received");
|
debug("headlines_callback: returned no data");
|
||||||
|
f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug("headlines_callback: returned no data");
|
if (headlines) {
|
||||||
notify_error("Error while trying to load more headlines");
|
if (headlines_count > 0) {
|
||||||
|
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("no new headlines received");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
debug("headlines_callback: returned no data");
|
||||||
|
notify_error("Error while trying to load more headlines");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if (articles) {
|
||||||
|
for (var i = 0; i < articles.length; i++) {
|
||||||
if (articles) {
|
var a_id = articles[i].getAttribute("id");
|
||||||
for (var i = 0; i < articles.length; i++) {
|
debug("found id: " + a_id);
|
||||||
var a_id = articles[i].getAttribute("id");
|
cache_inject(a_id, articles[i].firstChild.nodeValue);
|
||||||
debug("found id: " + a_id);
|
}
|
||||||
cache_inject(a_id, articles[i].firstChild.nodeValue);
|
} else {
|
||||||
|
debug("no cached articles received");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (counters) {
|
||||||
|
debug("parsing piggybacked counters: " + counters);
|
||||||
|
parse_counters(counters, false);
|
||||||
|
} else {
|
||||||
|
debug("counters container not found in reply");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runtime_info) {
|
||||||
|
debug("parsing runtime info: " + runtime_info[0]);
|
||||||
|
parse_runtime_info(runtime_info[0]);
|
||||||
|
} else {
|
||||||
|
debug("counters container not found in reply");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
debug("no cached articles received");
|
debug("headlines_callback: returned no XML object");
|
||||||
|
f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counters) {
|
if (typeof correctPNG != 'undefined') {
|
||||||
debug("parsing piggybacked counters: " + counters);
|
correctPNG();
|
||||||
parse_counters(counters, false);
|
|
||||||
} else {
|
|
||||||
debug("counters container not found in reply");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runtime_info) {
|
if (_cdm_wd_timeout) window.clearTimeout(_cdm_wd_timeout);
|
||||||
debug("parsing runtime info: " + runtime_info[0]);
|
|
||||||
parse_runtime_info(runtime_info[0]);
|
if (!document.getElementById("headlinesList") &&
|
||||||
|
getInitParam("cdm_auto_catchup") == 1) {
|
||||||
|
debug("starting CDM watchdog");
|
||||||
|
_cdm_wd_timeout = window.setTimeout("cdmWatchdog()", 5000);
|
||||||
|
_cdm_wd_vishist = new Array();
|
||||||
} else {
|
} else {
|
||||||
debug("counters container not found in reply");
|
debug("not in CDM mode or watchdog disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
if (_tag_cdm_scroll) {
|
||||||
debug("headlines_callback: returned no XML object");
|
try {
|
||||||
f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
|
document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll;
|
||||||
|
_tag_cdm_scroll = false;
|
||||||
|
debug("resetting headlinesInner scrollTop");
|
||||||
|
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
_feed_cur_page = feed_cur_page;
|
||||||
|
|
||||||
|
notify("");
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("headlines_callback2", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof correctPNG != 'undefined') {
|
|
||||||
correctPNG();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_cdm_wd_timeout) window.clearTimeout(_cdm_wd_timeout);
|
|
||||||
|
|
||||||
if (!document.getElementById("headlinesList") &&
|
|
||||||
getInitParam("cdm_auto_catchup") == 1) {
|
|
||||||
debug("starting CDM watchdog");
|
|
||||||
_cdm_wd_timeout = window.setTimeout("cdmWatchdog()", 5000);
|
|
||||||
_cdm_wd_vishist = new Array();
|
|
||||||
} else {
|
|
||||||
debug("not in CDM mode or watchdog disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_tag_cdm_scroll) {
|
|
||||||
try {
|
|
||||||
document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll;
|
|
||||||
_tag_cdm_scroll = false;
|
|
||||||
debug("resetting headlinesInner scrollTop");
|
|
||||||
|
|
||||||
} catch (e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
_feed_cur_page = feed_cur_page;
|
|
||||||
|
|
||||||
notify("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_article(article) {
|
function render_article(article) {
|
||||||
|
|
Loading…
Reference in a new issue