aggiunto by

This commit is contained in:
Matteo Manzinello
2019-05-04 01:40:58 +02:00
parent a2a47b1f39
commit dbfaccd687
5 changed files with 96 additions and 3631 deletions

25
dist/mailgo.js vendored
View File

@@ -75,6 +75,15 @@ let styles = `
margin-top: 10px;
padding: 16px 10px;
}
.mailgo-by {
display: block;
font-size: 8px;
padding: 5px;
margin-top: 0.75rem;
}
.mailgo-by:hover {
background-color: none;
}
`;
// CSS
@@ -121,6 +130,12 @@ mailgos.forEach((mailgo, index) => {
strong.appendChild(strongContent);
modalContent.appendChild(strong);
// details
let details = document.createElement("div");
details.className = "mailgo-details";
modalContent.appendChild(details);
// Gmail
let gmail = document.createElement("a");
gmail.href = "https://mail.google.com/mail?extsrc=mailto&url=" + mailgo.href;
@@ -164,6 +179,16 @@ mailgos.forEach((mailgo, index) => {
);
modalContent.appendChild(copy);
// details
let by = document.createElement("a");
by.href = "https://mailgo.js.org";
by.className = "mailgo-by";
let textBy = document.createTextNode("mailgo.js.org");
by.appendChild(textBy);
modalContent.appendChild(by);
mailgo.parentNode.insertBefore(modal, mailgo.nextSibling);
mailgo.addEventListener(

2
dist/mailgo.min.js vendored
View File

@@ -1 +1 @@
let mailgos=document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)'),styles='\n\n .mailgo-modal {\n all: initial;\n * {\n all: unset;\n }\n }\n\n .mailgo-title {\n display: block;\n margin-bottom: 16px;\n }\n\n .mailgo-modal-background {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(10,10,10,.86);\n opacity: 0.8;\n }\n .mailgo-modal {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: none;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";\n }\n .mailgo-modal.is-active {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .mailgo-modal-content {\n z-index: 1000;\n text-align: center;\n width: 200px;\n background-color: #fff;\n border-radius: 6px;\n box-shadow: 0 2px 3px rgba(10,10,10,.1), 0 0 0 1px rgba(10,10,10,.1);\n color: #4a4a4a;\n display: block;\n padding: 1.25rem;\n }\n .mailgo-modal-content a {\n display: block;\n color: #4a4a4a;\n padding: 10px;\n border-radius: 4px;\n text-decoration: none;\n }\n .mailgo-modal-content a:hover {\n background-color: rgba(0, 0, 0, 0.08);\n }\n .mailgo-modal-content a.outlook {\n color: rgba(0, 114, 198);\n }\n .mailgo-modal-content a.gmail {\n color: rgba(212, 70, 56);\n }\n .mailgo-modal-content a.outlook:hover {\n background-color: rgba(0, 114, 198, 0.08);\n }\n .mailgo-modal-content a.gmail:hover {\n background-color: rgba(212, 70, 56, 0.08);\n }\n a.mailgo-copy {\n margin-top: 10px;\n padding: 16px 10px;\n }\n',styleSheet=document.createElement("style");function 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)}function 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 n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);t.select(),document.execCommand("copy"),document.body.removeChild(t),n&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n))}styleSheet.type="text/css",styleSheet.innerText=styles,document.head.appendChild(styleSheet),console.log("mailgo is WIP!"),mailgos.forEach((e,t)=>{let n=e.href.split("?")[0].split("mailto:")[1].trim();if(!validateEmail(n))return;let o=new URL(e.href),a=new URLSearchParams(o.search),l=(a.get("subject"),a.get("body"),a.get("cc"),a.get("bcc"),document.createElement("div"));l.className="mailgo-modal",l.setAttribute("data-index",t);let i=document.createElement("div");i.className="mailgo-modal-background",l.appendChild(i);let d=document.createElement("div");d.className="mailgo-modal-content",l.appendChild(d);let c=document.createElement("strong");c.className="mailgo-title";let m=document.createTextNode(n);c.appendChild(m),d.appendChild(c);let r=document.createElement("a");r.href="https://mail.google.com/mail?extsrc=mailto&url="+e.href,r.classList.add("mailgo-open"),r.classList.add("gmail");let s=document.createTextNode("open in Gmail");r.appendChild(s),d.appendChild(r);let p=document.createElement("a");p.href="https://outlook.office.com/owa/?rru=compose&to="+n+o.search,p.classList.add("mailgo-open"),p.classList.add("outlook");let g=document.createTextNode("open in Outlook");p.appendChild(g),d.appendChild(p);let u=document.createElement("a");u.href=e.href,u.className="mailgo-open";let h=document.createTextNode("open");u.appendChild(h),d.appendChild(u);let b=document.createElement("a");b.href="#mailgo-copy",b.className="mailgo-copy";let y=document.createTextNode("copy");b.appendChild(y),b.addEventListener("click",e=>{copyToClipboard(n),b.innerHTML="copied!"},!1),d.appendChild(b),e.parentNode.insertBefore(l,e.nextSibling),e.addEventListener("click",t=>{t.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1),i.addEventListener("click",t=>{e.nextElementSibling.classList.remove("is-active")},!1)});
let mailgos=document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)'),styles='\n\n .mailgo-modal {\n all: initial;\n * {\n all: unset;\n }\n }\n\n .mailgo-title {\n display: block;\n margin-bottom: 16px;\n }\n\n .mailgo-modal-background {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(10,10,10,.86);\n opacity: 0.8;\n }\n .mailgo-modal {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: none;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";\n }\n .mailgo-modal.is-active {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .mailgo-modal-content {\n z-index: 1000;\n text-align: center;\n width: 200px;\n background-color: #fff;\n border-radius: 6px;\n box-shadow: 0 2px 3px rgba(10,10,10,.1), 0 0 0 1px rgba(10,10,10,.1);\n color: #4a4a4a;\n display: block;\n padding: 1.25rem;\n }\n .mailgo-modal-content a {\n display: block;\n color: #4a4a4a;\n padding: 10px;\n border-radius: 4px;\n text-decoration: none;\n }\n .mailgo-modal-content a:hover {\n background-color: rgba(0, 0, 0, 0.08);\n }\n .mailgo-modal-content a.outlook {\n color: rgba(0, 114, 198);\n }\n .mailgo-modal-content a.gmail {\n color: rgba(212, 70, 56);\n }\n .mailgo-modal-content a.outlook:hover {\n background-color: rgba(0, 114, 198, 0.08);\n }\n .mailgo-modal-content a.gmail:hover {\n background-color: rgba(212, 70, 56, 0.08);\n }\n a.mailgo-copy {\n margin-top: 10px;\n padding: 16px 10px;\n }\n .mailgo-by {\n display: block;\n font-size: 8px;\n padding: 5px;\n margin-top: 0.75rem;\n }\n .mailgo-by:hover {\n background-color: none;\n }\n',styleSheet=document.createElement("style");function 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)}function copyToClipboard(e){const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="absolute",n.style.left="-9999px",document.body.appendChild(n);const t=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);n.select(),document.execCommand("copy"),document.body.removeChild(n),t&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(t))}styleSheet.type="text/css",styleSheet.innerText=styles,document.head.appendChild(styleSheet),console.log("mailgo is WIP!"),mailgos.forEach((e,n)=>{let t=e.href.split("?")[0].split("mailto:")[1].trim();if(!validateEmail(t))return;let o=new URL(e.href),a=new URLSearchParams(o.search),l=(a.get("subject"),a.get("body"),a.get("cc"),a.get("bcc"),document.createElement("div"));l.className="mailgo-modal",l.setAttribute("data-index",n);let i=document.createElement("div");i.className="mailgo-modal-background",l.appendChild(i);let d=document.createElement("div");d.className="mailgo-modal-content",l.appendChild(d);let c=document.createElement("strong");c.className="mailgo-title";let m=document.createTextNode(t);c.appendChild(m),d.appendChild(c);let r=document.createElement("div");r.className="mailgo-details",d.appendChild(r);let s=document.createElement("a");s.href="https://mail.google.com/mail?extsrc=mailto&url="+e.href,s.classList.add("mailgo-open"),s.classList.add("gmail");let p=document.createTextNode("open in Gmail");s.appendChild(p),d.appendChild(s);let g=document.createElement("a");g.href="https://outlook.office.com/owa/?rru=compose&to="+t+o.search,g.classList.add("mailgo-open"),g.classList.add("outlook");let u=document.createTextNode("open in Outlook");g.appendChild(u),d.appendChild(g);let h=document.createElement("a");h.href=e.href,h.className="mailgo-open";let b=document.createTextNode("open");h.appendChild(b),d.appendChild(h);let y=document.createElement("a");y.href="#mailgo-copy",y.className="mailgo-copy";let x=document.createTextNode("copy");y.appendChild(x),y.addEventListener("click",e=>{copyToClipboard(t),y.innerHTML="copied!"},!1),d.appendChild(y);let f=document.createElement("a");f.href="https://mailgo.js.org",f.className="mailgo-by";let C=document.createTextNode("mailgo.js.org");f.appendChild(C),d.appendChild(f),e.parentNode.insertBefore(l,e.nextSibling),e.addEventListener("click",n=>{n.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1),i.addEventListener("click",n=>{e.nextElementSibling.classList.remove("is-active")},!1)});