syndicatefx / textpad

A simple online notepad, no WYSIWYG, no fancy stuff, just write.
MIT License
103 stars 28 forks source link

What about sending the text by mail? #3

Open gaffling opened 5 years ago

gaffling commented 5 years ago

I implement the following for me and it works nice ;-) by the way nice little tool you made!!

Add in the app.js file this:

document.addEventListener("DOMContentLoaded", function(event) {

  // Declare our variables

  var title   = document.getElementById("fileName"),
      content = document.getElementById("fileContent"),
      start   = document.getElementById("start"),
      home    = document.getElementById("homepage"),
      send    = document.getElementById("send"),
...

and later in the same file:

  // Send File(icon)

  send.addEventListener("click", function(event) {
    event.preventDefault();
    if(title.value == "") {
      smoke.prompt("Please give your email a subject!\n or just keep the default below.", function(e) {
        if(e) {
          title.value = e;
          localStorage.setItem("textPad-title", e);
          var link = "mailto:"
             + "?subject=" + escape(title.value)
             + "&body=" + escape(content.value);
          window.location.href = link;
        }
      }, {
        reverseButtons: true,
        value: "my-text-file",
        ok: "Send",
        cancel: "Cancel"
      });
    } else {
      var link = "mailto:"
          + "?subject=" + escape(title.value)
          + "&body=" + escape(content.value);
      window.location.href = link;
    };

  }, false);

and in the app.css file this:

.send-btn:hover svg {
  fill: #971ffd;
}

and in the index.html file add the following:

<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns:xlink="http://www.w3.org/1999/xlink"><defs>

<symbol id="icon-file-send" viewBox="0 0 24 24"><title>file-send</title><polygon points="3 12 8.61 14.992 17 8 9 17.455 9 21 12.164 16.887 18 20 21 3 3 12"/></symbol>

and later on:

<div class="btn-group">

        <button id="send" class="send-btn" title="Send Text by eMail"><svg><use xlink:href="#icon-file-send"></use></svg></button>

Please let me know what you think about that ;-)

syndicatefx commented 5 years ago

Hi @adilbo Sorry for the very very late response. I've been neglecting my projects on Github for a while, busy with work, family, and just to lazy :)

This is really a cool idea, and definitely a feature i would like to add. I've been thinking about tweaking the UI and when i get around to do it i will include this feature for sure.

Thanks, have a good one!

gaffling commented 5 years ago

Hi @syndicatefx Oh, thanks for your response - i have already a solution for me implemented that also work with longer text (it split the text in several eMails, because a mailto: link should not be to long ;-) write m if you are interested in that. ;-)