From ddcbbea2deb6d9d6abc3f3925aac55073c0b38ac Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 29 Nov 2010 14:21:28 +0300 Subject: [PATCH] tag setting rpc: use JSON --- modules/backend-rpc.php | 6 +++--- viewfeed.js | 35 ++++++++++++----------------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index e027ff39..bf475e63 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -364,6 +364,7 @@ } if ($subop == "setArticleTags") { + header("Content-Type: text/plain"); global $memcache; @@ -425,9 +426,8 @@ $tags_str = format_tags_string(get_article_tags($link, $id), $id); - print " - - "; + print json_encode(array("tags_str" => array("id" => $id, + "content" => $tags_str))); return; } diff --git a/viewfeed.js b/viewfeed.js index 22523fa1..7919fe35 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -1065,15 +1065,6 @@ function catchupSelection() { } function editArticleTags(id) { -/* displayDlg('editArticleTags', id, - function () { - $("tags_str").focus(); - - new Ajax.Autocompleter('tags_str', 'tags_choices', - "backend.php?op=rpc&subop=completeTags", - { tokens: ',', paramName: "search" }); - }); */ - var query = "backend.php?op=dlg&id=editArticleTags¶m=" + param_escape(id); if (dijit.byId("editTagsDlg")) @@ -1095,21 +1086,19 @@ function editArticleTags(id) { notify(''); dialog.hide(); - if (transport.responseXML) { - var tags_str = transport.responseXML.getElementsByTagName("tags-str")[0]; - - if (tags_str) { - var id = tags_str.getAttribute("id"); - - if (id) { - var tags = $("ATSTR-" + id); - if (tags) { - tags.innerHTML = tags_str.firstChild.nodeValue; - } - - cache_invalidate(id); - } + var data = JSON.parse(transport.responseText); + + if (data) { + var tags_str = data.tags_str; + var id = tags_str.id; + + var tags = $("ATSTR-" + id); + + if (tags) { + tags.innerHTML = tags_str.content; } + + cache_invalidate(id); } }}); -- 2.39.5