]>
git.wh0rd.org - tt-rss.git/blob - plugins/share/share.js
1 function shareArticle(id
) {
3 if (dijit
.byId("shareArticleDlg"))
4 dijit
.byId("shareArticleDlg").destroyRecursive();
6 var query
= "backend.php?op=pluginhandler&plugin=share&method=shareArticle¶m=" + param_escape(id
);
8 dialog
= new dijit
.Dialog({
10 title
: __("Share article by URL"),
11 style
: "width: 600px",
13 if (confirm(__("Generate new share URL for this article?"))) {
15 notify_progress("Trying to change URL...", true);
17 const query
= { op
: "pluginhandler", plugin
: "share", method
: "newkey", id
: id
};
19 xhrJson("backend.php", query
, (reply
) => {
21 const new_link
= reply
.link
;
22 const e
= $('gen_article_url');
26 e
.innerHTML
= e
.innerHTML
.replace(/\&key=.*$/,
27 "&key=" + new_link
);
29 e
.href
= e
.href
.replace(/\&key=.*$/,
32 new Effect
.Highlight(e
);
34 const img
= $("SHARE-IMG-" + id
);
35 if (img
) img
.src
= img
.src
.replace("notshared.png", "share.png");
40 notify_error("Could not change URL.");
48 if (confirm(__("Remove sharing for this article?"))) {
50 notify_progress("Trying to unshare...", true);
52 const query
= { op
: "pluginhandler", plugin
: "share", method
: "unshare", id
: id
};
54 xhrPost("backend.php", query
, () => {
55 notify("Article unshared.");
57 var img
= $("SHARE-IMG-" + id
);
58 if (img
) img
.src
= img
.src
.replace("share.png", "notshared.png");
69 const img
= $("SHARE-IMG-" + id
);
70 if (img
) img
.src
= img
.src
.replace("notshared.png", "share.png");
73 exception_error("shareArticle", e
);