1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 20:35:55 +00:00

plugins: add some xhrPost refactoring

This commit is contained in:
Andrew Dolgov
2018-11-30 15:23:48 +03:00
parent 764434a491
commit 2f961ee830
5 changed files with 54 additions and 99 deletions

View File

@@ -14,36 +14,33 @@ function shareArticle(id) {
notify_progress("Trying to change URL...", true);
var query = "op=pluginhandler&plugin=share&method=newkey&id=" + param_escape(id);
const query = { op: "pluginhandler", plugin: "share", method: "newkey", id: id };
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
var reply = JSON.parse(transport.responseText);
var new_link = reply.link;
xhrJson("backend.php", query, (reply) => {
if (reply) {
const new_link = reply.link;
const e = $('gen_article_url');
var e = $('gen_article_url');
if (new_link) {
if (new_link) {
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
"&key=" + new_link);
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
"&key=" + new_link);
e.href = e.href.replace(/\&key=.*$/,
"&key=" + new_link);
e.href = e.href.replace(/\&key=.*$/,
"&key=" + new_link);
new Effect.Highlight(e);
new Effect.Highlight(e);
const img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("notshared.png", "share.png");
var img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("notshared.png", "share.png");
notify('');
} else {
notify_error("Could not change URL.");
}
} });
notify('');
} else {
notify_error("Could not change URL.");
}
}
});
}
},
@@ -52,18 +49,16 @@ function shareArticle(id) {
notify_progress("Trying to unshare...", true);
var query = "op=pluginhandler&plugin=share&method=unshare&id=" + param_escape(id);
const query = { op: "pluginhandler", plugin: "share", method: "unshare", id: id };
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
notify("Article unshared.");
xhrPost("backend.php", query, () => {
notify("Article unshared.");
var img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("share.png", "notshared.png");
var img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("share.png", "notshared.png");
dialog.hide();
} });
dialog.hide();
});
}
},
@@ -71,7 +66,7 @@ function shareArticle(id) {
dialog.show();
var img = $("SHARE-IMG-" + id);
const img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("notshared.png", "share.png");
} catch (e) {