]> git.wh0rd.org - tt-rss.git/blob - plugins/share/share.js
remove ok = confirm() thing
[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 if (confirm(__("Generate new share URL for this article?"))) {
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
37 var img = $("SHARE-IMG-" + id);
38 if (img) img.src = img.src.replace("notshared.png", "share.png");
39
40 notify('');
41
42 } else {
43 notify_error("Could not change URL.");
44 }
45 } });
46
47 }
48
49 },
50 unshare: function() {
51 if (confirm(__("Remove sharing for this article?"))) {
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.");
61
62 var img = $("SHARE-IMG-" + id);
63 if (img) img.src = img.src.replace("share.png", "notshared.png");
64
65 dialog.hide();
66 } });
67 }
68
69 },
70 href: query});
71
72 dialog.show();
73
74 var img = $("SHARE-IMG-" + id);
75 if (img) img.src = img.src.replace("notshared.png", "share.png");
76
77 } catch (e) {
78 exception_error("shareArticle", e);
79 }
80 }
81
82