From eec0f14a35e050ce149276c3169b968ee5cb1abc Mon Sep 17 00:00:00 2001 From: Matteo Manzinello Date: Tue, 21 May 2019 09:13:13 +0200 Subject: [PATCH] actions object --- dist/mailgo.js | 60 ++++++++++++++++++++--------------------- dist/mailgo.min.js | 2 +- src/mailgo.js | 66 ++++++++++++++++++++++++---------------------- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/dist/mailgo.js b/dist/mailgo.js index 8d6f4ca..edfc9b2 100644 --- a/dist/mailgo.js +++ b/dist/mailgo.js @@ -217,17 +217,17 @@ var mailgoRender = function mailgoRender(mailgo) { bodyMail ? (bodyEl.style.display = "block", bodyValueEl.textContent = bodyMail) : bodyEl.style.display = "none"; // add the actions gmailButton.addEventListener("click", function () { - openGmailAction(mailtoHref); + actions.openGmail(mailtoHref); }, false); outlookButton.addEventListener("click", function () { - openOutlookAction(mail, url); + actions.openOutlook(mail, url); }, false); var encEmail = encodeEmail(mail); openButton.addEventListener("click", function () { - openDefaultAction(encEmail); + actions.openDefault(encEmail); }, false); copyButton.addEventListener("click", function (event) { - copyAction(mail, copyButton); + actions.copy(mail, copyButton); }, false); // show the mailgo showMailgo(); // listener keyDown @@ -238,24 +238,23 @@ var mailgoRender = function mailgoRender(mailgo) { }; // actions -var openGmailAction = function openGmailAction(mailtoHref) { - window.open("https://mail.google.com/mail?extsrc=mailto&url=" + encodeURIComponent(mailtoHref), "_blank"); -}; - -var openOutlookAction = function openOutlookAction(mail, url) { - window.open("https://outlook.office.com/owa/?rru=compose&to=" + encodeURIComponent(mail) + url.search.replace(/^[$]/, "&"), "_blank"); -}; - -var openDefaultAction = function openDefaultAction(encEmail) { - mailToEncoded(encEmail); -}; - -var copyAction = function copyAction(mail, copyButton) { - copyToClipboard(mail); - copyButton.textContent = "copied"; - var timeout = setTimeout(function () { - copyButton.textContent = "copy"; - }, 999); +var actions = { + openGmail: function openGmail(mailtoHref) { + window.open("https://mail.google.com/mail?extsrc=mailto&url=" + encodeURIComponent(mailtoHref), "_blank"); + }, + openOutlook: function openOutlook(mail, url) { + window.open("https://outlook.office.com/owa/?rru=compose&to=" + encodeURIComponent(mail) + url.search.replace(/^[$]/, "&"), "_blank"); + }, + openDefault: function openDefault(encEmail) { + mailToEncoded(encEmail); + }, + copy: function copy(mail, copyButton) { + copyToClipboard(mail); + copyButton.textContent = "copied"; + var timeout = setTimeout(function () { + copyButton.textContent = "copy"; + }, 999); + } }; /** * mailgoCheckRender @@ -265,7 +264,6 @@ var copyAction = function copyAction(mail, copyButton) { * ); and the new a[mailgo] */ - var mailgoCheckRender = function mailgoCheckRender(event) { // the target element var e = event.target; // check if the id=mailgo exists in the body @@ -291,7 +289,7 @@ var mailgoCheckRender = function mailgoCheckRender(event) { var mailgoKeydown = function mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton) { // if mailgo is not showing do nothing - if (mailgoHidden()) return; + if (!mailgoIsShowing()) return; switch (event.keyCode) { case 27: @@ -301,23 +299,23 @@ var mailgoKeydown = function mailgoKeydown(mail, url, mailtoHref, encEmail, copy case 71: // g -> open GMail - openGmailAction(mailtoHref); + actions.openGmail(mailtoHref); break; case 79: // o -> open Outlook - openOutlookAction(mail, url); + actions.openOutlook(mail, url); break; case 32: case 13: // spacebar or enter -> open default - openDefaultAction(encEmail); + actions.openDefault(encEmail); break; case 67: // c -> copy - copyAction(mail, copyButton); + actions.copy(mail, copyButton); break; default: @@ -330,7 +328,7 @@ var mailgoKeydown = function mailgoKeydown(mail, url, mailtoHref, encEmail, copy document.addEventListener("DOMContentLoaded", mailgoInit, false); // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered -document.body.addEventListener("click", mailgoCheckRender, false); // validate the email with regex +document.body.addEventListener("click", mailgoCheckRender, true); // validate the email with regex var validateEmail = function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\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,}))$/; @@ -367,8 +365,8 @@ var hideMailgo = function hideMailgo() { }; // is the modal hidden? -var mailgoHidden = function mailgoHidden() { - return getE("mailgo").style.display === "none"; +var mailgoIsShowing = function mailgoIsShowing() { + return getE("mailgo").style.display === "flex"; }; // decrypt email diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index 9ac235d..ca0884f 100644 --- a/dist/mailgo.min.js +++ b/dist/mailgo.min.js @@ -1 +1 @@ -"use strict";var V="0.4.0",MAILTO="mailto:",mailgoCSS=document.createElement("link");mailgoCSS.rel="stylesheet",mailgoCSS.type="text/css",mailgoCSS.href="https://unpkg.com/mailgo@"+V+"/dist/mailgo.min.css",document.head.appendChild(mailgoCSS);var mailgoInit=function(){var e=document.createElement("div");e.id="mailgo",e.classList.add("mailgo-modal"),e.style.display="none";var t=document.createElement("div");t.className="mailgo-modal-background",e.appendChild(t);var a=document.createElement("div");a.className="mailgo-modal-content",e.appendChild(a);var o=document.createElement("strong");o.id="mailgo-title",o.className="mailgo-title",a.appendChild(o);var n=document.createElement("div");n.id="mailgo-details",n.className="mailgo-details";var i=document.createElement("p");i.id="mailgo-cc";var l=document.createElement("span");l.className="mailgo-weight-500";var d=document.createTextNode("cc ");l.appendChild(d);var c=document.createElement("span");c.id="mailgo-cc-value",i.appendChild(l),i.appendChild(c),n.appendChild(i);var m=document.createElement("p");m.id="mailgo-bcc";var r=document.createElement("span");r.className="mailgo-weight-500";var s=document.createTextNode("bcc ");r.appendChild(s);var p=document.createElement("span");p.id="mailgo-bcc-value",m.appendChild(r),m.appendChild(p),n.appendChild(m);var g=document.createElement("p");g.id="mailgo-subject";var u=document.createElement("span");u.className="mailgo-weight-500";var h=document.createTextNode("subject");u.appendChild(h);var v=document.createElement("span");v.id="mailgo-subject-value",g.appendChild(u),g.appendChild(v),n.appendChild(g);var C=document.createElement("p");C.id="mailgo-body";var E=document.createElement("span");E.className="mailgo-weight-500";var y=document.createTextNode("body ");E.appendChild(y);var b=document.createElement("span");b.id="mailgo-body-value",C.appendChild(E),C.appendChild(b),n.appendChild(C),a.appendChild(n);var f=document.createElement("a");f.id="mailgo-gmail",f.href="#mailgo-gmail",f.classList.add("mailgo-open"),f.classList.add("mailgo-gmail");var k=document.createTextNode("open in ");f.appendChild(k);var A=document.createElement("span");A.className="mailgo-weight-500";var L=document.createTextNode("Gmail");A.appendChild(L),f.appendChild(A),a.appendChild(f);var w=document.createElement("a");w.id="mailgo-outlook",w.href="#mailgo-outlook",w.classList.add("mailgo-open"),w.classList.add("mailgo-outlook");var x=document.createTextNode("open in ");w.appendChild(x);var N=document.createElement("span");N.className="mailgo-weight-500";var T=document.createTextNode("Outlook");N.appendChild(T),w.appendChild(N),a.appendChild(w);var S=document.createElement("a");S.id="mailgo-open",S.href="#mailgo-open",S.classList.add("mailgo-open"),S.classList.add("mailgo-default");var R=document.createElement("span");R.className="mailgo-weight-500";var I=document.createTextNode("open");R.appendChild(I);var M=document.createTextNode(" default");S.appendChild(R),S.appendChild(M),a.appendChild(S);var O=document.createElement("a");O.id="mailgo-copy",O.href="#mailgo-copy",O.classList.add("mailgo-copy"),O.classList.add("mailgo-weight-500");var j=document.createTextNode("copy");O.appendChild(j),a.appendChild(O);var U=document.createElement("a");U.href="https://mailgo.js.org",U.className="mailgo-by",U.target="_blank",U.rel="noopener noreferrer";var D=document.createTextNode("mailgo.js.org");U.appendChild(D),a.appendChild(U),document.body.appendChild(e),t.addEventListener("click",hideMailgo,!1)},mailgoRender=function(e){var t="",a="",o="",n="",i="",l="",d="";if(e.href&&e.href.toLowerCase().startsWith(MAILTO)){t=decodeURIComponent(e.href.split("?")[0].split(MAILTO)[1].trim()),o=e.href,a=new URL(o);var c=new URLSearchParams(a.search);n=c.get("cc"),i=c.get("bcc"),l=c.get("subject"),d=c.get("body")}else t=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain"),o=MAILTO+encodeURIComponent(t),a=new URL(o),n=e.getAttribute("data-cc-address")+"@"+e.getAttribute("data-cc-domain"),i=e.getAttribute("data-bcc-address")+"@"+e.getAttribute("data-bcc-domain"),l=e.getAttribute("data-subject"),d=e.getAttribute("data-body");if(validateEmail(t)){validateEmail(n)||(n=""),validateEmail(i)||(i="");var m=getE("mailgo-title"),r=(getE("mailgo-details"),getE("mailgo-cc")),s=getE("mailgo-cc-value"),p=getE("mailgo-bcc"),g=getE("mailgo-bcc-value"),u=getE("mailgo-subject"),h=getE("mailgo-subject-value"),v=getE("mailgo-body"),C=getE("mailgo-body-value"),E=getE("mailgo-gmail"),y=getE("mailgo-outlook"),b=getE("mailgo-open"),f=getE("mailgo-copy");m.textContent=t,n?(r.style.display="block",s.textContent=n):r.style.display="none",i?(p.style.display="block",g.textContent=i):p.style.display="none",l?(u.style.display="block",h.textContent=l):u.style.display="none",d?(v.style.display="block",C.textContent=d):v.style.display="none",E.addEventListener("click",function(){openGmailAction(o)},!1),y.addEventListener("click",function(){openOutlookAction(t,a)},!1);var k=encodeEmail(t);b.addEventListener("click",function(){openDefaultAction(k)},!1),f.addEventListener("click",function(e){copyAction(t,f)},!1),showMailgo(),document.body.addEventListener("keydown",function(){mailgoKeydown(t,a,o,k,f)},!1)}},openGmailAction=function(e){window.open("https://mail.google.com/mail?extsrc=mailto&url="+encodeURIComponent(e),"_blank")},openOutlookAction=function(e,t){window.open("https://outlook.office.com/owa/?rru=compose&to="+encodeURIComponent(e)+t.search.replace(/^[$]/,"&"),"_blank")},openDefaultAction=function(e){mailToEncoded(e)},copyAction=function(e,t){copyToClipboard(e),t.textContent="copied";setTimeout(function(){t.textContent="copy"},999)},mailgoCheckRender=function(e){var t=e.target;document.body.contains(getE("mailgo"))&&(t.href&&t.href.toLowerCase().startsWith(MAILTO)&&!t.classList.contains("no-mailgo")||t.href&&"#mailgo"===t.getAttribute("href").toLowerCase()||t.classList.contains("mailgo")||t.getAttribute("mailgo"))&&(e.preventDefault(),mailgoRender(t))},mailgoKeydown=function(e,t,a,o,n){if(!mailgoHidden())switch(event.keyCode){case 27:hideMailgo();break;case 71:openGmailAction(a);break;case 79:openOutlookAction(e,t);break;case 32:case 13:openDefaultAction(o);break;case 67:copyAction(e,n);break;default:return}};document.addEventListener("DOMContentLoaded",mailgoInit,!1),document.body.addEventListener("click",mailgoCheckRender,!1);var validateEmail=function(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=function(e){var t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);var 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))},showMailgo=function(){getE("mailgo").style.display="flex"},hideMailgo=function(){getE("mailgo").style.display="none"},mailgoHidden=function(){return"none"===getE("mailgo").style.display},mailToEncoded=function(e){return window.location.href=MAILTO+atob(e)},encodeEmail=function(e){return btoa(e)},getE=function(e){return document.getElementById(e)}; \ No newline at end of file +"use strict";var V="0.4.0",MAILTO="mailto:",mailgoCSS=document.createElement("link");mailgoCSS.rel="stylesheet",mailgoCSS.type="text/css",mailgoCSS.href="https://unpkg.com/mailgo@"+V+"/dist/mailgo.min.css",document.head.appendChild(mailgoCSS);var mailgoInit=function(){var e=document.createElement("div");e.id="mailgo",e.classList.add("mailgo-modal"),e.style.display="none";var t=document.createElement("div");t.className="mailgo-modal-background",e.appendChild(t);var a=document.createElement("div");a.className="mailgo-modal-content",e.appendChild(a);var o=document.createElement("strong");o.id="mailgo-title",o.className="mailgo-title",a.appendChild(o);var n=document.createElement("div");n.id="mailgo-details",n.className="mailgo-details";var i=document.createElement("p");i.id="mailgo-cc";var l=document.createElement("span");l.className="mailgo-weight-500";var d=document.createTextNode("cc ");l.appendChild(d);var c=document.createElement("span");c.id="mailgo-cc-value",i.appendChild(l),i.appendChild(c),n.appendChild(i);var m=document.createElement("p");m.id="mailgo-bcc";var r=document.createElement("span");r.className="mailgo-weight-500";var s=document.createTextNode("bcc ");r.appendChild(s);var p=document.createElement("span");p.id="mailgo-bcc-value",m.appendChild(r),m.appendChild(p),n.appendChild(m);var g=document.createElement("p");g.id="mailgo-subject";var u=document.createElement("span");u.className="mailgo-weight-500";var h=document.createTextNode("subject");u.appendChild(h);var v=document.createElement("span");v.id="mailgo-subject-value",g.appendChild(u),g.appendChild(v),n.appendChild(g);var C=document.createElement("p");C.id="mailgo-body";var E=document.createElement("span");E.className="mailgo-weight-500";var y=document.createTextNode("body ");E.appendChild(y);var b=document.createElement("span");b.id="mailgo-body-value",C.appendChild(E),C.appendChild(b),n.appendChild(C),a.appendChild(n);var f=document.createElement("a");f.id="mailgo-gmail",f.href="#mailgo-gmail",f.classList.add("mailgo-open"),f.classList.add("mailgo-gmail");var k=document.createTextNode("open in ");f.appendChild(k);var L=document.createElement("span");L.className="mailgo-weight-500";var w=document.createTextNode("Gmail");L.appendChild(w),f.appendChild(L),a.appendChild(f);var x=document.createElement("a");x.id="mailgo-outlook",x.href="#mailgo-outlook",x.classList.add("mailgo-open"),x.classList.add("mailgo-outlook");var N=document.createTextNode("open in ");x.appendChild(N);var T=document.createElement("span");T.className="mailgo-weight-500";var A=document.createTextNode("Outlook");T.appendChild(A),x.appendChild(T),a.appendChild(x);var S=document.createElement("a");S.id="mailgo-open",S.href="#mailgo-open",S.classList.add("mailgo-open"),S.classList.add("mailgo-default");var I=document.createElement("span");I.className="mailgo-weight-500";var R=document.createTextNode("open");I.appendChild(R);var M=document.createTextNode(" default");S.appendChild(I),S.appendChild(M),a.appendChild(S);var O=document.createElement("a");O.id="mailgo-copy",O.href="#mailgo-copy",O.classList.add("mailgo-copy"),O.classList.add("mailgo-weight-500");var j=document.createTextNode("copy");O.appendChild(j),a.appendChild(O);var U=document.createElement("a");U.href="https://mailgo.js.org",U.className="mailgo-by",U.target="_blank",U.rel="noopener noreferrer";var D=document.createTextNode("mailgo.js.org");U.appendChild(D),a.appendChild(U),document.body.appendChild(e),t.addEventListener("click",hideMailgo,!1)},mailgoRender=function(e){var t="",a="",o="",n="",i="",l="",d="";if(e.href&&e.href.toLowerCase().startsWith(MAILTO)){t=decodeURIComponent(e.href.split("?")[0].split(MAILTO)[1].trim()),o=e.href,a=new URL(o);var c=new URLSearchParams(a.search);n=c.get("cc"),i=c.get("bcc"),l=c.get("subject"),d=c.get("body")}else t=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain"),o=MAILTO+encodeURIComponent(t),a=new URL(o),n=e.getAttribute("data-cc-address")+"@"+e.getAttribute("data-cc-domain"),i=e.getAttribute("data-bcc-address")+"@"+e.getAttribute("data-bcc-domain"),l=e.getAttribute("data-subject"),d=e.getAttribute("data-body");if(validateEmail(t)){validateEmail(n)||(n=""),validateEmail(i)||(i="");var m=getE("mailgo-title"),r=(getE("mailgo-details"),getE("mailgo-cc")),s=getE("mailgo-cc-value"),p=getE("mailgo-bcc"),g=getE("mailgo-bcc-value"),u=getE("mailgo-subject"),h=getE("mailgo-subject-value"),v=getE("mailgo-body"),C=getE("mailgo-body-value"),E=getE("mailgo-gmail"),y=getE("mailgo-outlook"),b=getE("mailgo-open"),f=getE("mailgo-copy");m.textContent=t,n?(r.style.display="block",s.textContent=n):r.style.display="none",i?(p.style.display="block",g.textContent=i):p.style.display="none",l?(u.style.display="block",h.textContent=l):u.style.display="none",d?(v.style.display="block",C.textContent=d):v.style.display="none",E.addEventListener("click",function(){actions.openGmail(o)},!1),y.addEventListener("click",function(){actions.openOutlook(t,a)},!1);var k=encodeEmail(t);b.addEventListener("click",function(){actions.openDefault(k)},!1),f.addEventListener("click",function(e){actions.copy(t,f)},!1),showMailgo(),document.body.addEventListener("keydown",function(){mailgoKeydown(t,a,o,k,f)},!1)}},actions={openGmail:function(e){window.open("https://mail.google.com/mail?extsrc=mailto&url="+encodeURIComponent(e),"_blank")},openOutlook:function(e,t){window.open("https://outlook.office.com/owa/?rru=compose&to="+encodeURIComponent(e)+t.search.replace(/^[$]/,"&"),"_blank")},openDefault:function(e){mailToEncoded(e)},copy:function(e,t){copyToClipboard(e),t.textContent="copied";setTimeout(function(){t.textContent="copy"},999)}},mailgoCheckRender=function(e){var t=e.target;document.body.contains(getE("mailgo"))&&(t.href&&t.href.toLowerCase().startsWith(MAILTO)&&!t.classList.contains("no-mailgo")||t.href&&"#mailgo"===t.getAttribute("href").toLowerCase()||t.classList.contains("mailgo")||t.getAttribute("mailgo"))&&(e.preventDefault(),mailgoRender(t))},mailgoKeydown=function(e,t,a,o,n){if(mailgoIsShowing())switch(event.keyCode){case 27:hideMailgo();break;case 71:actions.openGmail(a);break;case 79:actions.openOutlook(e,t);break;case 32:case 13:actions.openDefault(o);break;case 67:actions.copy(e,n);break;default:return}};document.addEventListener("DOMContentLoaded",mailgoInit,!1),document.body.addEventListener("click",mailgoCheckRender,!0);var validateEmail=function(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=function(e){var t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);var 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))},showMailgo=function(){getE("mailgo").style.display="flex"},hideMailgo=function(){getE("mailgo").style.display="none"},mailgoIsShowing=function(){return"flex"===getE("mailgo").style.display},mailToEncoded=function(e){return window.location.href=MAILTO+atob(e)},encodeEmail=function(e){return btoa(e)},getE=function(e){return document.getElementById(e)}; \ No newline at end of file diff --git a/src/mailgo.js b/src/mailgo.js index d16c93d..66c94bf 100644 --- a/src/mailgo.js +++ b/src/mailgo.js @@ -277,7 +277,7 @@ const mailgoRender = mailgo => { gmailButton.addEventListener( "click", () => { - openGmailAction(mailtoHref); + actions.openGmail(mailtoHref); }, false ); @@ -285,7 +285,7 @@ const mailgoRender = mailgo => { outlookButton.addEventListener( "click", () => { - openOutlookAction(mail, url); + actions.openOutlook(mail, url); }, false ); @@ -294,7 +294,7 @@ const mailgoRender = mailgo => { openButton.addEventListener( "click", () => { - openDefaultAction(encEmail); + actions.openDefault(encEmail); }, false ); @@ -302,7 +302,7 @@ const mailgoRender = mailgo => { copyButton.addEventListener( "click", event => { - copyAction(mail, copyButton); + actions.copy(mail, copyButton); }, false ); @@ -321,33 +321,35 @@ const mailgoRender = mailgo => { }; // actions -let openGmailAction = mailtoHref => { - window.open( - "https://mail.google.com/mail?extsrc=mailto&url=" + - encodeURIComponent(mailtoHref), - "_blank" - ); -}; +const actions = { + openGmail: mailtoHref => { + window.open( + "https://mail.google.com/mail?extsrc=mailto&url=" + + encodeURIComponent(mailtoHref), + "_blank" + ); + }, -let openOutlookAction = (mail, url) => { - window.open( - "https://outlook.office.com/owa/?rru=compose&to=" + - encodeURIComponent(mail) + - url.search.replace(/^[$]/, "&"), - "_blank" - ); -}; + openOutlook: (mail, url) => { + window.open( + "https://outlook.office.com/owa/?rru=compose&to=" + + encodeURIComponent(mail) + + url.search.replace(/^[$]/, "&"), + "_blank" + ); + }, -let openDefaultAction = encEmail => { - mailToEncoded(encEmail); -}; + openDefault: encEmail => { + mailToEncoded(encEmail); + }, -let copyAction = (mail, copyButton) => { - copyToClipboard(mail); - copyButton.textContent = "copied"; - let timeout = setTimeout(() => { - copyButton.textContent = "copy"; - }, 999); + copy: (mail, copyButton) => { + copyToClipboard(mail); + copyButton.textContent = "copied"; + let timeout = setTimeout(() => { + copyButton.textContent = "copy"; + }, 999); + } }; /** @@ -398,20 +400,20 @@ const mailgoKeydown = (mail, url, mailtoHref, encEmail, copyButton) => { break; case 71: // g -> open GMail - openGmailAction(mailtoHref); + actions.openGmail(mailtoHref); break; case 79: // o -> open Outlook - openOutlookAction(mail, url); + actions.openOutlook(mail, url); break; case 32: case 13: // spacebar or enter -> open default - openDefaultAction(encEmail); + actions.openDefault(encEmail); break; case 67: // c -> copy - copyAction(mail, copyButton); + actions.copy(mail, copyButton); break; default: return;