]> git.wh0rd.org Git - tt-rss.git/commitdiff
rpc/addfeed: use JSON
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Nov 2010 13:02:16 +0000 (16:02 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Nov 2010 13:02:37 +0000 (16:02 +0300)
functions.js
modules/backend-rpc.php

index ed4f4712282197451848ca2d2d5bff14e64240db..f0364deb053aa86704faaf9714254b737855bcb5 100644 (file)
@@ -865,15 +865,10 @@ function quickAddFeed() {
                                                parameters: dojo.objectToQuery(this.attr('value')),
                                                onComplete: function(transport) { 
                                                        try {
+
+                                                               var reply = JSON.parse(transport.responseText);
                                
-                                                               if (!transport.responseXML) {
-                                                                       console.log(transport.responseText);
-                                                                       alert(__("Server error while trying to subscribe to specified feed."));
-                                                                       return;
-                                                               }
-                               
-                                                               var result = transport.responseXML.getElementsByTagName('result')[0];
-                                                               var rc = parseInt(result.getAttribute('code'));
+                                                               var rc = parseInt(reply['result']);
                                        
                                                                notify('');
 
@@ -899,16 +894,11 @@ function quickAddFeed() {
                                                                                parameters: 'op=rpc&subop=extractfeedurls&url=' + param_escape(feed_url),
                                                                                onComplete: function(transport, dialog, feed_url) {
 
-                                                                                       if (!transport.responseXML) {
-                                                                                               console.log(transport.responseText);
-                                                                                               alert(__("Server error while trying to query feed URLs."));
-                                                                                               return;
-                                                                                       }
-       
                                                                                        notify('');
 
-                                                                                       var result = transport.responseXML.getElementsByTagName('urls')[0];
-                                                                                       var feeds = JSON.parse(result.firstChild.nodeValue);
+                                                                                       var reply = JSON.parse(transport.responseText);
+
+                                                                                       var feeds = reply['urls'];
 
                                                                                        console.log(transport.responseText);
 
index bf475e633ea8aa0316d0d0725b22d1f3dd949109..54c66df33b0b3b7506b0c9900ed9cba22bf1d9dc 100644 (file)
@@ -88,8 +88,6 @@
                if ($subop == "remarchive") {
                        $ids = split(",", db_escape_string($_REQUEST["ids"]));
 
-                       print "<rpc-reply>";
-
                        foreach ($ids as $id) {
                                $result = db_query($link, "DELETE FROM ttrss_archived_feeds WHERE
                                        (SELECT COUNT(*) FROM ttrss_user_entries 
                                                id = '$id' AND owner_uid = ".$_SESSION["uid"]);
 
                                $rc = db_affected_rows($link, $result);
-
-                               print "<feed id='$id' rc='$rc'/>";
-
                        }
 
-                       print "</rpc-reply>";
-
                        return;
                }
 
                if ($subop == "addfeed") {
+                       header("Content-Type: text/plain");
 
                        $feed = db_escape_string($_REQUEST['feed']);
                        $cat = db_escape_string($_REQUEST['cat']);
 
                        $rc = subscribe_to_feed($link, $feed, $cat, $login, $pass);
 
-                       print "<rpc-reply>";
-                       print "<result code='$rc'/>";
-                       print "</rpc-reply>";
+                       print json_encode(array("result" => $rc));
 
                        return;
 
                }
 
                if ($subop == "extractfeedurls") {
-                       print "<rpc-reply>";
+                       header("Content-Type: text/plain");
 
                        $urls = get_feeds_from_html($_REQUEST['url']);
-                       print "<urls><![CDATA[" . json_encode($urls) . "]]></urls>";
 
-                       print "</rpc-reply>";
+                       print json_encode(array("urls" => $urls));
                        return;
                }