]> git.wh0rd.org - tt-rss.git/blob - plugins/mail/mail.js
plugins: add some xhrPost refactoring
[tt-rss.git] / plugins / mail / mail.js
1 function emailArticle(id) {
2 try {
3 if (!id) {
4 var ids = getSelectedArticleIds2();
5
6 if (ids.length == 0) {
7 alert(__("No articles are selected."));
8 return;
9 }
10
11 id = ids.toString();
12 }
13
14 if (dijit.byId("emailArticleDlg"))
15 dijit.byId("emailArticleDlg").destroyRecursive();
16
17 var query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle&param=" + param_escape(id);
18
19 dialog = new dijit.Dialog({
20 id: "emailArticleDlg",
21 title: __("Forward article by email"),
22 style: "width: 600px",
23 execute: function() {
24 if (this.validate()) {
25 xhrJson("backend.php", this.attr('value'), (reply) => {
26 if (reply) {
27 const error = reply['error'];
28
29 if (error) {
30 alert(__('Error sending email:') + ' ' + error);
31 } else {
32 notify_info('Your message has been sent.');
33 dialog.hide();
34 }
35
36 }
37 });
38 }
39 },
40 href: query});
41
42 /* var tmph = dojo.connect(dialog, 'onLoad', function() {
43 dojo.disconnect(tmph);
44
45 new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
46 "backend.php?op=pluginhandler&plugin=mail&method=completeEmails",
47 { tokens: '', paramName: "search" });
48 }); */
49
50 dialog.show();
51
52 } catch (e) {
53 exception_error("emailArticle", e);
54 }
55 }
56
57