1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ttrss_ynh.git synced 2024-10-01 13:34:46 +02:00
ttrss_ynh/source/plugins/share/share.js
2013-11-24 11:03:28 +01:00

88 lines
2 KiB
JavaScript

function shareArticle(id) {
try {
if (dijit.byId("shareArticleDlg"))
dijit.byId("shareArticleDlg").destroyRecursive();
var query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle&param=" + param_escape(id);
dialog = new dijit.Dialog({
id: "shareArticleDlg",
title: __("Share article by URL"),
style: "width: 600px",
newurl: function() {
var ok = confirm(__("Generate new share URL for this article?"));
if (ok) {
notify_progress("Trying to change URL...", true);
var query = "op=pluginhandler&plugin=share&method=newkey&id=" + param_escape(id);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
var reply = JSON.parse(transport.responseText);
var new_link = reply.link;
var e = $('gen_article_url');
if (new_link) {
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
"&key=" + new_link);
e.href = e.href.replace(/\&key=.*$/,
"&key=" + new_link);
new Effect.Highlight(e);
var img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("notshared.png", "share.png");
notify('');
} else {
notify_error("Could not change URL.");
}
} });
}
},
unshare: function() {
var ok = confirm(__("Remove sharing for this article?"));
if (ok) {
notify_progress("Trying to unshare...", true);
var query = "op=pluginhandler&plugin=share&method=unshare&id=" + param_escape(id);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
notify("Article unshared.");
var img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("share.png", "notshared.png");
dialog.hide();
} });
}
},
href: query});
dialog.show();
var img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("notshared.png", "share.png");
} catch (e) {
exception_error("shareArticle", e);
}
}