]> git.wh0rd.org - tt-rss.git/blob - plugins/share/share.js
Merge branch 'master' of git://github.com/syrnon/Tiny-Tiny-RSS into syrnon-master
[tt-rss.git] / plugins / share / share.js
1 function shareArticle(id) {
2 try {
3 if (dijit.byId("shareArticleDlg"))
4 dijit.byId("shareArticleDlg").destroyRecursive();
5
6 var query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle&param=" + param_escape(id);
7
8 dialog = new dijit.Dialog({
9 id: "shareArticleDlg",
10 title: __("Share article by URL"),
11 style: "width: 600px",
12 newurl: function() {
13
14 var ok = confirm(__("Generate new share URL for this article?"));
15
16 if (ok) {
17
18 notify_progress("Trying to change URL...", true);
19
20 var query = "op=pluginhandler&plugin=share&method=newkey&id=" + param_escape(id);
21
22 new Ajax.Request("backend.php", {
23 parameters: query,
24 onComplete: function(transport) {
25 var reply = JSON.parse(transport.responseText);
26 var new_link = reply.link;
27
28 var e = $('gen_article_url');
29
30 if (new_link) {
31
32 e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
33 "&key=" + new_link);
34
35 e.href = e.href.replace(/\&key=.*$/,
36 "&key=" + new_link);
37
38 new Effect.Highlight(e);
39
40 notify('');
41
42 } else {
43 notify_error("Could not change URL.");
44 }
45 } });
46
47 }
48
49 },
50 unshare: function() {
51
52 var ok = confirm(__("Remove sharing for this article?"));
53
54 if (ok) {
55
56 notify_progress("Trying to unshare...", true);
57
58 var query = "op=pluginhandler&plugin=share&method=unshare&id=" + param_escape(id);
59
60 new Ajax.Request("backend.php", {
61 parameters: query,
62 onComplete: function(transport) {
63 notify("Article unshared.");
64 dialog.hide();
65 } });
66 }
67
68 },
69 href: query});
70
71 dialog.show();
72
73 } catch (e) {
74 exception_error("shareArticle", e);
75 }
76 }
77
78