use xhrPost in even more places!

master
Andrew Dolgov 6 years ago
parent ed1262d55a
commit eaf7cfdba6

@ -855,16 +855,11 @@ function deleteSelection() {
return;
}
const query = "?op=rpc&method=delete&ids=" + param_escape(rows);
const query = { op: "rpc", method: "delete", ids: rows.toString() };
console.log(query);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
viewCurrentFeed();
}
});
}
@ -899,21 +894,16 @@ function archiveSelection() {
return;
}
const query = "?op=rpc&method="+op+"&ids=" + param_escape(rows);
console.log(query);
for (let i = 0; i < rows.length; i++) {
cache_delete("article:" + rows[i]);
}
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
const query = {op: "rpc", method: op, ids: rows.toString()};
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
viewCurrentFeed();
} });
});
}
function catchupSelection() {
@ -955,9 +945,7 @@ function editArticleTags(id) {
notify_progress("Saving article tags...", true);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
xhrPost("backend.php", this.attr('value'), (transport) => {
try {
notify('');
dialog.hide();
@ -967,8 +955,6 @@ function editArticleTags(id) {
if (data) {
const id = data.id;
console.log(id);
const tags = $("ATSTR-" + id);
const tooltip = dijit.byId("ATSTRTIP-" + id);
@ -978,8 +964,7 @@ function editArticleTags(id) {
} catch (e) {
exception_error(e);
}
}});
});
}
},
href: query
@ -1165,21 +1150,17 @@ function catchupBatchedArticles() {
// make a copy of the array
const batch = catchup_id_batch.slice();
const query = "?op=rpc&method=catchupSelected" +
"&cmode=0&ids=" + param_escape(batch.toString());
console.log(query);
const query = { op: "rpc", method: "catchupSelected",
cmode: 0, ids: batch.toString() };
_catchup_request_sent = true;
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
handle_rpc_json(transport);
xhrPost("backend.php", query, (transport) => {
const reply = handle_rpc_json(transport);
_catchup_request_sent = false;
const reply = JSON.parse(transport.responseText);
if (reply) {
const batch = reply.ids;
batch.each(function (id) {
@ -1188,10 +1169,9 @@ function catchupBatchedArticles() {
if (elem) elem.removeClassName("Unread");
catchup_id_batch.remove(id);
});
}
updateFloatingTitle(true);
}
});
}
}
@ -1247,16 +1227,12 @@ function catchupRelativeToArticle(below, id) {
e.removeClassName("Unread");
}
const query = "?op=rpc&method=catchupSelected" +
"&cmode=0" + "&ids=" + param_escape(ids_to_mark.toString());
const query = { op: "rpc", method: "catchupSelected",
cmode: 0, ids: ids_to_mark.toString() };
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
}
});
}
}
}
@ -1424,17 +1400,16 @@ function cdmClicked(event, id, in_body) {
if (article_is_unread) {
decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
updateFloatingTitle(true);
}
const query = "?op=rpc&method=catchupSelected" +
"&cmode=0&ids=" + param_escape(id);
const query = {
op: "rpc", method: "catchupSelected",
cmode: 0, ids: id
};
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
}
});
}
return !event.shiftKey;
}
@ -1812,17 +1787,12 @@ function setSelectionScore() {
const score = prompt(__("Please enter new score for selected articles:"));
if (score != undefined) {
const query = "op=article&method=setScore&id=" + param_escape(ids.toString()) +
"&score=" + param_escape(score);
const query = { op: "article", method: "setScore", id: ids.toString(),
score: score };
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
const reply = JSON.parse(transport.responseText);
xhrJson("backend.php", query, (reply) => {
if (reply) {
console.log(ids);
ids.each(function (id) {
reply.id.each((id) => {
const row = $("RROW-" + id);
if (row) {
@ -1831,12 +1801,11 @@ function setSelectionScore() {
if (pic) {
pic.src = pic.src.replace(/score_.*?\.png/,
reply["score_pic"]);
pic.setAttribute("score", score);
pic.setAttribute("score", reply["score"]);
}
}
});
}
}
});
}
@ -1845,6 +1814,7 @@ function setSelectionScore() {
}
}
/*
function updateScore(id) {
const pic = $$("#RROW-" + id + " .hlScorePic")[0];
@ -1867,7 +1837,7 @@ function updateScore(id) {
}
});
}
}
} */
function changeScore(id, pic) {
const score = pic.getAttribute("score");
@ -1875,38 +1845,27 @@ function changeScore(id, pic) {
const new_score = prompt(__("Please enter new score for this article:"), score);
if (new_score != undefined) {
const query = { op: "article", method: "setScore", id: id, score: new_score };
const query = "op=article&method=setScore&id=" + param_escape(id) +
"&score=" + param_escape(new_score);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
const reply = JSON.parse(transport.responseText);
xhrJson("backend.php", query, (reply) => {
if (reply) {
pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
pic.setAttribute("score", new_score);
pic.setAttribute("title", new_score);
}
}
});
}
}
function displayArticleUrl(id) {
const query = "op=rpc&method=getlinktitlebyid&id=" + param_escape(id);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
const reply = JSON.parse(transport.responseText);
const query = { op: "rpc", method: "getlinktitlebyid", id: id };
xhrJson("backend.php", query, (reply) => {
if (reply && reply.link) {
prompt(__("Article URL:"), reply.link);
}
}
});
}
function scrollToRowId(id) {

Loading…
Cancel
Save