]> git.wh0rd.org Git - tt-rss.git/commitdiff
headlines_callback: async
authorAndrew Dolgov <fox@madoka.spb.ru>
Fri, 24 Aug 2007 04:59:12 +0000 (05:59 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Fri, 24 Aug 2007 04:59:12 +0000 (05:59 +0100)
feedlist.js
viewfeed.js

index ec1a653de2d84a42bcfa8c80c7fe530f693d44d4..c78a47d5cb2ac7672bac25948113b1fef00a3758 100644 (file)
@@ -1,6 +1,6 @@
 //var xmlhttp = Ajax.getTransport();
 
-var feed_cur_page = 0;
+var _feed_cur_page = 0;
 
 function viewCategory(cat) {
        active_feed_is_cat = true;
@@ -50,10 +50,10 @@ function viewNextFeedPage() {
        try {
                if (!getActiveFeedId()) return;
 
-               feed_cur_page++;
+               _feed_cur_page++;
 
                viewfeed(getActiveFeedId(), undefined, undefined, undefined,
-                       undefined, feed_cur_page);
+                       undefined, _feed_cur_page);
 
        } catch (e) {
                exception_error(e, "viewFeedGoPage");
@@ -71,11 +71,11 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
                        page_offset = offset;
                } else {
                        page_offset = 0;
-                       feed_cur_page = 0;
+                       _feed_cur_page = 0;
                }
 
                if (getActiveFeedId() != feed) {
-                       feed_cur_page = 0;
+                       _feed_cur_page = 0;
                        active_post_id = 0;
                }
 
@@ -178,13 +178,18 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
 
 //             xmlhttp.abort();
 
-               if (xmlhttp_ready(xmlhttp)) {
+/*             if (xmlhttp_ready(xmlhttp)) {
                        xmlhttp.open("GET", query, true);
                        xmlhttp.onreadystatechange=headlines_callback;
                        xmlhttp.send(null);
                } else {
                        debug("xmlhttp busy (@feeds)");
-               }  
+               }  */
+
+               new Ajax.Request(query, {
+                       onComplete: function(transport) { 
+                               headlines_callback2(transport, feed, is_cat, _feed_cur_page); 
+                       } });
 
        } catch (e) {
                exception_error("viewfeed", e);
index 30af548c0edc998e4ed575fcbb224ff9fa714ac4..197b7648bc68a0c8e1bdcabd0fcda9a5311366c2 100644 (file)
@@ -45,104 +45,102 @@ function catchup_callback2(transport, callback) {
        }
 }
 
-function headlines_callback() {
-       if (xmlhttp.readyState == 4) {
-               debug("headlines_callback");
-               var f = document.getElementById("headlines-frame");
-               try {
-                       if (feed_cur_page == 0) { 
-                               debug("resetting headlines scrollTop");
-                               f.scrollTop = 0; 
-                       }
-               } catch (e) { };
+function headlines_callback2(transport, active_feed_id, active_feed_is_cat, feed_cur_page) {
+       debug("headlines_callback2");
+       var f = document.getElementById("headlines-frame");
+       try {
+               if (feed_cur_page == 0) { 
+                       debug("resetting headlines scrollTop");
+                       f.scrollTop = 0; 
+               }
+       } catch (e) { };
 
-               if (xmlhttp.responseXML) {
-                       var headlines = xmlhttp.responseXML.getElementsByTagName("headlines")[0];
-                       var counters = xmlhttp.responseXML.getElementsByTagName("counters")[0];
-                       var articles = xmlhttp.responseXML.getElementsByTagName("article");
-                       var runtime_info = xmlhttp.responseXML.getElementsByTagName("runtime-info");
+       if (transport.responseXML) {
+               var headlines = transport.responseXML.getElementsByTagName("headlines")[0];
+               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>";
-       
-                               }
+               if (feed_cur_page == 0) {
+                       if (headlines) {
+                               f.innerHTML = headlines.firstChild.nodeValue;
                        } else {
-                               if (headlines) {
-                                       debug("adding some more headlines...");
+                               debug("headlines_callback: returned no data");
+                       f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
 
-                                       var c = document.getElementById("headlinesList");
+                       }
+               } else {
+                       if (headlines) {
+                               debug("adding some more headlines...");
 
-                                       if (!c) {
-                                               c = document.getElementById("headlinesInnerContainer");
-                                       }
+                               var c = document.getElementById("headlinesList");
 
-                                       c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
-                               } else {
-                                       debug("headlines_callback: returned no data");
-                                       notify_error("Error while trying to load more headlines");      
+                               if (!c) {
+                                       c = document.getElementById("headlinesInnerContainer");
                                }
 
-                       }
-
-                       if (articles) {
-                               for (var i = 0; i < articles.length; i++) {
-                                       var a_id = articles[i].getAttribute("id");
-                                       debug("found id: " + a_id);
-                                       cache_inject(a_id, articles[i].firstChild.nodeValue);
-                               }
+                               c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
                        } else {
-                               debug("no cached articles received");
+                               debug("headlines_callback: returned no data");
+                               notify_error("Error while trying to load more headlines");      
                        }
 
-                       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");
+               if (articles) {
+                       for (var i = 0; i < articles.length; i++) {
+                               var a_id = articles[i].getAttribute("id");
+                               debug("found id: " + a_id);
+                               cache_inject(a_id, articles[i].firstChild.nodeValue);
                        }
-
                } else {
-                       debug("headlines_callback: returned no XML object");
-                       f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
+                       debug("no cached articles received");
                }
 
-               if (typeof correctPNG != 'undefined') {
-                       correctPNG();
+               if (counters) {
+                       debug("parsing piggybacked counters: " + counters);
+                       parse_counters(counters, false);
+               } else {
+                       debug("counters container not found in reply");
                }
 
-               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();
+               if (runtime_info) {
+                       debug("parsing runtime info: " + runtime_info[0]);
+                       parse_runtime_info(runtime_info[0]);
                } else {
-                       debug("not in CDM mode or watchdog disabled");
+                       debug("counters container not found in reply");
                }
 
-               if (_tag_cdm_scroll) {
-                       try {
-                               document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll;
-                               _tag_cdm_scroll = false;
-                               debug("resetting headlinesInner scrollTop");
+       } else {
+               debug("headlines_callback: returned no XML object");
+               f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
+       }
 
-                       } catch (e) { }
-               }
+       if (typeof correctPNG != 'undefined') {
+               correctPNG();
+       }
 
-               notify("");
+       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) { }
+       }
+
+       notify("");
 }
 
 function render_article(article) {