ttrss/plugins/mail/mail.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

/* global Plugins, Headlines, xhrJson, Notify, fox, __ */
Plugins.Mail = {
send: function(id) {
if (!id) {
const ids = Headlines.getSelected();
if (ids.length == 0) {
alert(__("No articles selected."));
return;
}
2011-12-21 04:46:39 +00:00
id = ids.toString();
2011-12-21 04:46:39 +00:00
}
const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle&param=" + encodeURIComponent(id);
2011-12-21 04:46:39 +00:00
const dialog = new fox.SingleUseDialog({
id: "emailArticleDlg",
title: __("Forward article by email"),
execute: function () {
if (this.validate()) {
xhrJson("backend.php", this.attr('value'), (reply) => {
if (reply) {
const error = reply['error'];
2011-12-21 04:46:39 +00:00
if (error) {
alert(__('Error sending email:') + ' ' + error);
} else {
Notify.info('Your message has been sent.');
dialog.hide();
}
2011-12-21 04:46:39 +00:00
}
});
}
},
href: query
});
/* var tmph = dojo.connect(dialog, 'onLoad', function() {
dojo.disconnect(tmph);
new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
"backend.php?op=pluginhandler&plugin=mail&method=completeEmails",
{ tokens: '', paramName: "search" });
}); */
dialog.show();
},
onHotkey: function(id) {
Plugins.Mail.send(id);
}
};