MAILGO_VERSION dynamically managed by gulp

This commit is contained in:
Matteo Manzinello 2019-05-09 14:52:24 +02:00
parent 87cd88b3ff
commit 3a1efd8daf
6 changed files with 60 additions and 7 deletions

2
dist/mailgo.js vendored
View File

@ -1,4 +1,4 @@
const version = "0.2.3";
const version = "0.2.4";
mailgoInit = () => {
const styleSheet = document.createElement("link");

2
dist/mailgo.min.js vendored
View File

@ -1 +1 @@
const version="0.2.3";mailgoInit=(()=>{const e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.href="https://unpkg.com/mailgo@0.2.3/dist/mailgo.min.css",document.head.appendChild(e),document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo), a[href="#mailgo"], a.mailgo').forEach((e,t)=>{let a="",l="",d="",n="",o="",c="";if(e.href&&e.href.includes("mailto:")){a=e.href.split("?")[0].split("mailto:")[1].trim(),l=e.href,url=new URL(l);let t=new URLSearchParams(url.search);d=t.get("cc"),n=t.get("bcc"),o=t.get("subject"),c=t.get("body")}else l="mailto:"+(a=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain")),url=new URL(l);if(!validateEmail(a))return;let i=document.createElement("div");i.classList.add("mailgo-modal"),i.setAttribute("data-index",t);let m=document.createElement("div");m.className="mailgo-modal-background",i.appendChild(m);let p=document.createElement("div");p.className="mailgo-modal-content",i.appendChild(p);let s=document.createElement("strong");s.className="mailgo-title";let r=document.createTextNode(a);s.appendChild(r),p.appendChild(s);let u=document.createElement("div");if(u.className="mailgo-details",d&&""!=d){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+d);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(n&&""!=n){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("bcc");t.appendChild(a);let l=document.createTextNode(": "+n);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(o&&""!=o){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+o);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(c&&""!=c){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+c);e.appendChild(t),e.appendChild(l),u.appendChild(e)}p.appendChild(u);let h=document.createElement("a");h.href="https://mail.google.com/mail?extsrc=mailto&url="+l,h.classList.add("mailgo-open"),h.classList.add("gmail");let g=document.createTextNode("open in ");h.appendChild(g);let C=document.createElement("span");C.className="mailgo-weight-500";let E=document.createTextNode("Gmail");C.appendChild(E),h.appendChild(C),p.appendChild(h);let N=document.createElement("a");N.href="https://outlook.office.com/owa/?rru=compose&to="+a+url.search,N.classList.add("mailgo-open"),N.classList.add("outlook");let f=document.createTextNode("open in ");N.appendChild(f);let x=document.createElement("span");x.className="mailgo-weight-500";let T=document.createTextNode("Outlook");x.appendChild(T),N.appendChild(x),p.appendChild(N);let L=document.createElement("a");L.href="#mailgo-open";let b=encryptEmail(a);L.addEventListener("click",()=>{mailToEncoded(b)},!1),L.classList.add("mailgo-open"),L.classList.add("mailgo-weight-500");let v=document.createTextNode("open");L.appendChild(v),p.appendChild(L);let y=document.createElement("a");y.href="#mailgo-copy",y.classList.add("mailgo-copy"),y.classList.add("mailgo-weight-500");let w=document.createTextNode("copy");y.appendChild(w),y.addEventListener("click",e=>{copyToClipboard(a),y.innerHTML="copied",setTimeout(()=>{y.innerHTML="copy"},999)},!1),p.appendChild(y);let k=document.createElement("a");k.href="https://mailgo.js.org",k.className="mailgo-by",k.target="_blank";let A=document.createTextNode("mailgo.js.org");k.appendChild(A),p.appendChild(k),e.parentNode.insertBefore(i,e.nextSibling),e.addEventListener("click",t=>{t.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1),m.addEventListener("click",t=>{e.nextElementSibling.classList.remove("is-active")},!1)})}),document.addEventListener("DOMContentLoaded",mailgoInit,!1),validateEmail=(e=>{return/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)}),copyToClipboard=(e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);const a=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);t.select(),document.execCommand("copy"),document.body.removeChild(t),a&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(a))}),mailToEncoded=(e=>window.location.href="mailto:"+atob(e)),encryptEmail=(e=>btoa(e));
const version="0.2.4";mailgoInit=(()=>{const e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.href="https://unpkg.com/mailgo@0.2.4/dist/mailgo.min.css",document.head.appendChild(e),document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo), a[href="#mailgo"], a.mailgo').forEach((e,t)=>{let a="",l="",d="",n="",o="",c="";if(e.href&&e.href.includes("mailto:")){a=e.href.split("?")[0].split("mailto:")[1].trim(),l=e.href,url=new URL(l);let t=new URLSearchParams(url.search);d=t.get("cc"),n=t.get("bcc"),o=t.get("subject"),c=t.get("body")}else l="mailto:"+(a=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain")),url=new URL(l);if(!validateEmail(a))return;let i=document.createElement("div");i.classList.add("mailgo-modal"),i.setAttribute("data-index",t);let m=document.createElement("div");m.className="mailgo-modal-background",i.appendChild(m);let p=document.createElement("div");p.className="mailgo-modal-content",i.appendChild(p);let s=document.createElement("strong");s.className="mailgo-title";let r=document.createTextNode(a);s.appendChild(r),p.appendChild(s);let u=document.createElement("div");if(u.className="mailgo-details",d&&""!=d){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+d);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(n&&""!=n){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("bcc");t.appendChild(a);let l=document.createTextNode(": "+n);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(o&&""!=o){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+o);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(c&&""!=c){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+c);e.appendChild(t),e.appendChild(l),u.appendChild(e)}p.appendChild(u);let h=document.createElement("a");h.href="https://mail.google.com/mail?extsrc=mailto&url="+l,h.classList.add("mailgo-open"),h.classList.add("gmail");let g=document.createTextNode("open in ");h.appendChild(g);let C=document.createElement("span");C.className="mailgo-weight-500";let E=document.createTextNode("Gmail");C.appendChild(E),h.appendChild(C),p.appendChild(h);let N=document.createElement("a");N.href="https://outlook.office.com/owa/?rru=compose&to="+a+url.search,N.classList.add("mailgo-open"),N.classList.add("outlook");let f=document.createTextNode("open in ");N.appendChild(f);let x=document.createElement("span");x.className="mailgo-weight-500";let T=document.createTextNode("Outlook");x.appendChild(T),N.appendChild(x),p.appendChild(N);let L=document.createElement("a");L.href="#mailgo-open";let b=encryptEmail(a);L.addEventListener("click",()=>{mailToEncoded(b)},!1),L.classList.add("mailgo-open"),L.classList.add("mailgo-weight-500");let v=document.createTextNode("open");L.appendChild(v),p.appendChild(L);let y=document.createElement("a");y.href="#mailgo-copy",y.classList.add("mailgo-copy"),y.classList.add("mailgo-weight-500");let w=document.createTextNode("copy");y.appendChild(w),y.addEventListener("click",e=>{copyToClipboard(a),y.innerHTML="copied",setTimeout(()=>{y.innerHTML="copy"},999)},!1),p.appendChild(y);let k=document.createElement("a");k.href="https://mailgo.js.org",k.className="mailgo-by",k.target="_blank";let A=document.createTextNode("mailgo.js.org");k.appendChild(A),p.appendChild(k),e.parentNode.insertBefore(i,e.nextSibling),e.addEventListener("click",t=>{t.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1),m.addEventListener("click",t=>{e.nextElementSibling.classList.remove("is-active")},!1)})}),document.addEventListener("DOMContentLoaded",mailgoInit,!1),validateEmail=(e=>{return/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)}),copyToClipboard=(e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);const a=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);t.select(),document.execCommand("copy"),document.body.removeChild(t),a&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(a))}),mailToEncoded=(e=>window.location.href="mailto:"+atob(e)),encryptEmail=(e=>btoa(e));

View File

@ -1,16 +1,21 @@
const { src, dest, parallel } = require("gulp");
const uglify = require("gulp-uglify");
const terser = require("gulp-terser");
const rename = require("gulp-rename");
const csso = require("gulp-csso");
const replace = require("gulp-replace");
let version = require("./package.json").version;
function js() {
return src("src/*.js").pipe(dest("dist"));
return src("src/*.js")
.pipe(replace("MAILGO_VERSION", version.toString()))
.pipe(dest("dist"));
}
function jsmin() {
return src("src/*.js")
.pipe(replace("MAILGO_VERSION", version))
.pipe(terser())
.pipe(
rename({

View File

@ -1,6 +1,6 @@
{
"name": "mailgo",
"version": "0.2.3",
"version": "0.2.4",
"description": "a different mailto",
"scripts": {
"build": "gulp"
@ -22,6 +22,7 @@
"gulp": "^4.0.2",
"gulp-csso": "^3.0.1",
"gulp-rename": "^1.4.0",
"gulp-replace": "^1.0.0",
"gulp-terser": "^1.1.7",
"gulp-uglify": "^3.0.2"
}

View File

@ -1,4 +1,4 @@
const version = "0.2.3";
const version = "MAILGO_VERSION";
mailgoInit = () => {
const styleSheet = document.createElement("link");

View File

@ -239,6 +239,11 @@ binary-extensions@^1.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65"
integrity sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==
binaryextensions@2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/binaryextensions/-/binaryextensions-2.1.2.tgz#c83c3d74233ba7674e4f313cb2a2b70f54e94b7c"
integrity sha512-xVNN69YGDghOqCCtA6FI7avYrr02mTJjOgB0/f1VPD3pJC8QEvjTKWc4epDx8AqxxA75NI0QpVM2gPJXUbE4Tg==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
@ -567,6 +572,11 @@ each-props@^1.3.0:
is-plain-object "^2.0.1"
object.defaults "^1.1.0"
editions@^1.3.3:
version "1.3.4"
resolved "https://registry.yarnpkg.com/editions/-/editions-1.3.4.tgz#3662cb592347c3168eb8e498a0ff73271d67f50b"
integrity sha512-gzao+mxnYDzIysXKMQi/+M1mjy/rjestjg6OPoYTtI+3Izp23oiGZitsl9lPDPiTGXbcSIk1iJWhliSaglxnUg==
end-of-stream@^1.0.0, end-of-stream@^1.1.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43"
@ -617,6 +627,11 @@ es6-weak-map@^2.0.1:
es6-iterator "^2.0.1"
es6-symbol "^3.1.1"
escape-string-regexp@^1.0.3:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
expand-brackets@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622"
@ -944,6 +959,15 @@ gulp-rename@^1.4.0:
resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-1.4.0.tgz#de1c718e7c4095ae861f7296ef4f3248648240bd"
integrity sha512-swzbIGb/arEoFK89tPY58vg3Ok1bw+d35PfUNwWqdo7KM4jkmuGA78JiDNqR+JeZFaeeHnRg9N7aihX3YPmsyg==
gulp-replace@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/gulp-replace/-/gulp-replace-1.0.0.tgz#b32bd61654d97b8d78430a67b3e8ce067b7c9143"
integrity sha512-lgdmrFSI1SdhNMXZQbrC75MOl1UjYWlOWNbNRnz+F/KHmgxt3l6XstBoAYIdadwETFyG/6i+vWUSCawdC3pqOw==
dependencies:
istextorbinary "2.2.1"
readable-stream "^2.0.1"
replacestream "^4.0.0"
gulp-terser@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/gulp-terser/-/gulp-terser-1.1.7.tgz#b011c05cc05661c3d2b629d114f419a90622462e"
@ -1278,6 +1302,15 @@ isobject@^3.0.0, isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
istextorbinary@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/istextorbinary/-/istextorbinary-2.2.1.tgz#a5231a08ef6dd22b268d0895084cf8d58b5bec53"
integrity sha512-TS+hoFl8Z5FAFMK38nhBkdLt44CclNRgDHWeMgsV8ko3nDlr/9UI2Sf839sW7enijf8oKsZYXRvM8g0it9Zmcw==
dependencies:
binaryextensions "2"
editions "^1.3.3"
textextensions "2"
json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
@ -1615,7 +1648,7 @@ number-is-nan@^1.0.0:
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
object-assign@^4.1.0:
object-assign@^4.0.1, object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
@ -1991,6 +2024,15 @@ replace-homedir@^1.0.0:
is-absolute "^1.0.0"
remove-trailing-separator "^1.1.0"
replacestream@^4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/replacestream/-/replacestream-4.0.3.tgz#3ee5798092be364b1cdb1484308492cb3dff2f36"
integrity sha512-AC0FiLS352pBBiZhd4VXB1Ab/lh0lEgpP+GGvZqbQh8a5cmXVoTe5EX/YeTFArnp4SRGTHh1qCHu9lGs1qG8sA==
dependencies:
escape-string-regexp "^1.0.3"
object-assign "^4.0.1"
readable-stream "^2.0.2"
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
@ -2316,6 +2358,11 @@ terser@^3.14.1:
source-map "~0.6.1"
source-map-support "~0.5.10"
textextensions@2:
version "2.4.0"
resolved "https://registry.yarnpkg.com/textextensions/-/textextensions-2.4.0.tgz#6a143a985464384cc2cff11aea448cd5b018e72b"
integrity sha512-qftQXnX1DzpSV8EddtHIT0eDDEiBF8ywhFYR2lI9xrGtxqKN+CvLXhACeCIGbCpQfxxERbrkZEFb8cZcDKbVZA==
through2-filter@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-3.0.0.tgz#700e786df2367c2c88cd8aa5be4cf9c1e7831254"