From: Andrew Dolgov Date: Sat, 6 Nov 2010 19:19:08 +0000 (+0300) Subject: headlines: use JSON instead of separate helper xml objects like headlines-unread X-Git-Tag: 1.5.0~390 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ffbe082dd0fcaf83658ac0a13ad1bdddeb4e0138;p=tt-rss.git headlines: use JSON instead of separate helper xml objects like headlines-unread --- diff --git a/backend.php b/backend.php index 52147205..761fc0dc 100644 --- a/backend.php +++ b/backend.php @@ -363,8 +363,8 @@ print "]]>"; - print ""; - print ""; + //print ""; + //print ""; $headlines_unread = ccache_find($link, $returned_feed, $_SESSION["uid"], $cat_view, true); @@ -374,8 +374,19 @@ } - print ""; - printf("", $disable_cache); + //print ""; + //printf("", $disable_cache); + + print " (int) $headlines_count, + "vgroup_last_feed" => $vgroup_last_feed, + "unread" => (int) $headlines_unread, + "disable_cache" => (bool) $disable_cache); + + print json_encode($info); + + print "]]>"; if ($_REQUEST["debug"]) $timing_info = print_checkpoint("10", $timing_info); diff --git a/functions.php b/functions.php index abc52b43..d5b3c436 100644 --- a/functions.php +++ b/functions.php @@ -6842,10 +6842,16 @@ print "]]>"; print ""; - print ""; - print ""; - print ""; - print ""; + print " 0, + "vgroup_last_feed" => '', + "unread" => 0, + "disable_cache" => true); + + print json_encode($info); + + print "]]>"; } diff --git a/viewfeed.js b/viewfeed.js index 1e9a11a1..5a0bf77e 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -107,18 +107,21 @@ function headlines_callback2(transport, feed_cur_page) { } catch (e) { }; if (transport.responseXML) { - var headlines = transport.responseXML.getElementsByTagName("headlines")[0]; - var headlines_count_obj = transport.responseXML.getElementsByTagName("headlines-count")[0]; - var headlines_unread_obj = transport.responseXML.getElementsByTagName("headlines-unread")[0]; - var disable_cache_obj = transport.responseXML.getElementsByTagName("disable-cache")[0]; + var response = transport.responseXML; - var vgroup_last_feed_obj = transport.responseXML.getElementsByTagName("vgroup-last-feed")[0]; + var headlines = response.getElementsByTagName("headlines")[0]; + var headlines_info = response.getElementsByTagName("headlines-info")[0]; - var headlines_count = headlines_count_obj.getAttribute("value"); - var headlines_unread = headlines_unread_obj.getAttribute("value"); - var disable_cache = disable_cache_obj.getAttribute("value") != "0"; + if (headlines_info) + headlines_info = JSON.parse(headlines_info.firstChild.nodeValue); + else + console.log("didn't find headlines-info object in response"); - vgroup_last_feed = vgroup_last_feed_obj.getAttribute("value"); + var headlines_count = headlines_info.count; + var headlines_unread = headlines_info.unread; + var disable_cache = headlines_info.disable_cache; + + vgroup_last_feed = headlines_info.vgroup_last_feed; if (headlines_count == 0) { _infscroll_disable = 1; @@ -126,9 +129,9 @@ function headlines_callback2(transport, feed_cur_page) { _infscroll_disable = 0; } - var counters = transport.responseXML.getElementsByTagName("counters")[0]; - var articles = transport.responseXML.getElementsByTagName("article"); - var runtime_info = transport.responseXML.getElementsByTagName("runtime-info"); + var counters = response.getElementsByTagName("counters")[0]; + var articles = response.getElementsByTagName("article"); + var runtime_info = response.getElementsByTagName("runtime-info"); if (feed_cur_page == 0) { if (headlines) {