1
0
mirror of https://tt-rss.org/git/tt-rss.git synced 2024-07-04 13:10:49 +02:00
ttrss/plugins/share/share.js

77 lines
1.8 KiB
JavaScript
Raw Normal View History

Plugins.Share = {
shareArticle: function(id) {
2011-12-21 05:46:39 +01:00
if (dijit.byId("shareArticleDlg"))
dijit.byId("shareArticleDlg").destroyRecursive();
const query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle&param=" + encodeURIComponent(id);
2011-12-21 05:46:39 +01:00
const dialog = new dijit.Dialog({
2011-12-21 05:46:39 +01:00
id: "shareArticleDlg",
title: __("Share article by URL"),
style: "width: 600px",
newurl: function () {
2018-11-30 11:05:59 +01:00
if (confirm(__("Generate new share URL for this article?"))) {
2018-12-02 18:56:30 +01:00
Notify.progress("Trying to change URL...", true);
const query = {op: "pluginhandler", plugin: "share", method: "newkey", id: id};
2018-11-30 13:23:48 +01:00
xhrJson("backend.php", query, (reply) => {
if (reply) {
const new_link = reply.link;
const e = $('gen_article_url');
2018-11-30 13:23:48 +01:00
if (new_link) {
2018-11-30 13:23:48 +01:00
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
"&key=" + new_link);
2018-11-30 13:23:48 +01:00
e.href = e.href.replace(/\&key=.*$/,
"&key=" + new_link);
2018-11-30 13:23:48 +01:00
new Effect.Highlight(e);
2018-11-30 13:23:48 +01:00
const img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("notshared.png", "share.png");
2018-12-02 18:56:30 +01:00
Notify.close();
2018-11-30 13:23:48 +01:00
} else {
2018-12-02 18:56:30 +01:00
Notify.error("Could not change URL.");
2018-11-30 13:23:48 +01:00
}
}
});
}
},
unshare: function () {
2018-11-30 11:05:59 +01:00
if (confirm(__("Remove sharing for this article?"))) {
2018-12-02 18:56:30 +01:00
Notify.progress("Trying to unshare...", true);
const query = {op: "pluginhandler", plugin: "share", method: "unshare", id: id};
2018-11-30 13:23:48 +01:00
xhrPost("backend.php", query, () => {
notify("Article unshared.");
2018-11-30 13:23:48 +01:00
var img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("share.png", "notshared.png");
2018-11-30 13:23:48 +01:00
dialog.hide();
});
}
},
href: query
});
2011-12-21 05:46:39 +01:00
dialog.show();
2018-11-30 13:23:48 +01:00
const img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("notshared.png", "share.png");
2011-12-21 05:46:39 +01:00
}
};
2011-12-21 05:46:39 +01:00