]> git.wh0rd.org - tt-rss.git/blobdiff - viewfeed.js
add article forwarding by email (closes #271)
[tt-rss.git] / viewfeed.js
index 1b8a1dab0b980ff166997cc01ca7f19b913be037..ac76be70bf2e190a303649c57a39f20caadef906 100644 (file)
@@ -2262,3 +2262,63 @@ function publishWithNote(id, def_note) {
                exception_error("publishWithNote", e);
        }
 }
+
+function emailArticle(id) {
+       try {
+               displayDlg('emailArticle', id, 
+                  function () {                                
+                               document.forms['article_email_form'].destination.focus();
+
+                          new Ajax.Autocompleter('destination', 'destination_choices',
+                                  "backend.php?op=rpc&subop=completeEmails",
+                                  { tokens: '', paramName: "search" });
+
+                       });
+
+       } catch (e) {
+               exception_error("emailArticle", e);
+       }
+}
+
+function emailArticleDo(id) {
+       try {
+               var f = document.forms['article_email_form'];
+
+               if (f.destination.value == "") {
+                       alert("Please fill in the destination email.");
+                       return;
+               }
+
+               if (f.subject.value == "") {
+                       alert("Please fill in the subject.");
+                       return;
+               }
+
+               var query = Form.serialize("article_email_form");
+
+//             console.log(query);
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) { 
+                               try {
+
+                                       var error = transport.responseXML.getElementsByTagName('error')[0];
+
+                                       if (error) {
+                                               alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue);
+                                       } else {
+                                               notify_info('Your message has been sent.');
+                                               closeInfoBox();
+                                       }
+
+                               } catch (e) {
+                                       exception_error("sendEmailDo", e);
+                               }
+
+                       } });
+
+       } catch (e) {
+               exception_error("emailArticleDo", e);
+       }
+}