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