textpad icon indicating copy to clipboard operation
textpad copied to clipboard

What about sending the text by mail?

Open gaffling opened this issue 5 years ago • 2 comments

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 ;-)

gaffling avatar Nov 05 '18 12:11 gaffling