mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 22:35:55 +00:00
headlines: use JSON instead of separate helper xml objects like headlines-unread
This commit is contained in:
19
backend.php
19
backend.php
@@ -363,8 +363,8 @@
|
|||||||
|
|
||||||
print "]]></headlines>";
|
print "]]></headlines>";
|
||||||
|
|
||||||
print "<headlines-count value=\"$headlines_count\"/>";
|
//print "<headlines-count value=\"$headlines_count\"/>";
|
||||||
print "<vgroup-last-feed value=\"$vgroup_last_feed\"/>";
|
//print "<vgroup-last-feed value=\"$vgroup_last_feed\"/>";
|
||||||
|
|
||||||
$headlines_unread = ccache_find($link, $returned_feed, $_SESSION["uid"],
|
$headlines_unread = ccache_find($link, $returned_feed, $_SESSION["uid"],
|
||||||
$cat_view, true);
|
$cat_view, true);
|
||||||
@@ -374,8 +374,19 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<headlines-unread value=\"$headlines_unread\"/>";
|
//print "<headlines-unread value=\"$headlines_unread\"/>";
|
||||||
printf("<disable-cache value=\"%d\"/>", $disable_cache);
|
//printf("<disable-cache value=\"%d\"/>", $disable_cache);
|
||||||
|
|
||||||
|
print "<headlines-info><![CDATA[";
|
||||||
|
|
||||||
|
$info = array("count" => (int) $headlines_count,
|
||||||
|
"vgroup_last_feed" => $vgroup_last_feed,
|
||||||
|
"unread" => (int) $headlines_unread,
|
||||||
|
"disable_cache" => (bool) $disable_cache);
|
||||||
|
|
||||||
|
print json_encode($info);
|
||||||
|
|
||||||
|
print "]]></headlines-info>";
|
||||||
|
|
||||||
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("10", $timing_info);
|
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("10", $timing_info);
|
||||||
|
|
||||||
|
|||||||
@@ -6842,10 +6842,16 @@
|
|||||||
print "</div>]]>";
|
print "</div>]]>";
|
||||||
print "</headlines>";
|
print "</headlines>";
|
||||||
|
|
||||||
print "<headlines-count value=\"0\"/>";
|
print "<headlines-info><![CDATA[";
|
||||||
print "<vgroup-last-feed value=\"0\"/>";
|
|
||||||
print "<headlines-unread value=\"0\"/>";
|
$info = array("count" => 0,
|
||||||
print "<disable-cache value=\"1\"/>";
|
"vgroup_last_feed" => '',
|
||||||
|
"unread" => 0,
|
||||||
|
"disable_cache" => true);
|
||||||
|
|
||||||
|
print json_encode($info);
|
||||||
|
|
||||||
|
print "]]></headlines-info>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
viewfeed.js
27
viewfeed.js
@@ -107,18 +107,21 @@ function headlines_callback2(transport, feed_cur_page) {
|
|||||||
} catch (e) { };
|
} catch (e) { };
|
||||||
|
|
||||||
if (transport.responseXML) {
|
if (transport.responseXML) {
|
||||||
var headlines = transport.responseXML.getElementsByTagName("headlines")[0];
|
var response = transport.responseXML;
|
||||||
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 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");
|
if (headlines_info)
|
||||||
var headlines_unread = headlines_unread_obj.getAttribute("value");
|
headlines_info = JSON.parse(headlines_info.firstChild.nodeValue);
|
||||||
var disable_cache = disable_cache_obj.getAttribute("value") != "0";
|
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) {
|
if (headlines_count == 0) {
|
||||||
_infscroll_disable = 1;
|
_infscroll_disable = 1;
|
||||||
@@ -126,9 +129,9 @@ function headlines_callback2(transport, feed_cur_page) {
|
|||||||
_infscroll_disable = 0;
|
_infscroll_disable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var counters = transport.responseXML.getElementsByTagName("counters")[0];
|
var counters = response.getElementsByTagName("counters")[0];
|
||||||
var articles = transport.responseXML.getElementsByTagName("article");
|
var articles = response.getElementsByTagName("article");
|
||||||
var runtime_info = transport.responseXML.getElementsByTagName("runtime-info");
|
var runtime_info = response.getElementsByTagName("runtime-info");
|
||||||
|
|
||||||
if (feed_cur_page == 0) {
|
if (feed_cur_page == 0) {
|
||||||
if (headlines) {
|
if (headlines) {
|
||||||
|
|||||||
Reference in New Issue
Block a user