introduction of getE
This commit is contained in:
parent
41b14b5ad8
commit
c981beb50f
40
dist/mailgo.js
vendored
40
dist/mailgo.js
vendored
@ -218,21 +218,21 @@ mailgoRender = mailgo => {
|
|||||||
// validate the email address
|
// validate the email address
|
||||||
if (!validateEmail(mail)) return;
|
if (!validateEmail(mail)) return;
|
||||||
|
|
||||||
titleEl = document.getElementById("mailgo-title");
|
titleEl = getE("mailgo-title");
|
||||||
detailsEl = document.getElementById("mailgo-details");
|
detailsEl = getE("mailgo-details");
|
||||||
ccEl = document.getElementById("mailgo-cc");
|
ccEl = getE("mailgo-cc");
|
||||||
ccValueEl = document.getElementById("mailgo-cc-value");
|
ccValueEl = getE("mailgo-cc-value");
|
||||||
bccEl = document.getElementById("mailgo-bcc");
|
bccEl = getE("mailgo-bcc");
|
||||||
bccValueEl = document.getElementById("mailgo-bcc-value");
|
bccValueEl = getE("mailgo-bcc-value");
|
||||||
subjectEl = document.getElementById("mailgo-subject");
|
subjectEl = getE("mailgo-subject");
|
||||||
subjectValueEl = document.getElementById("mailgo-subject-value");
|
subjectValueEl = getE("mailgo-subject-value");
|
||||||
bodyEl = document.getElementById("mailgo-body");
|
bodyEl = getE("mailgo-body");
|
||||||
bodyValueEl = document.getElementById("mailgo-body-value");
|
bodyValueEl = getE("mailgo-body-value");
|
||||||
|
|
||||||
gmailButton = document.getElementById("mailgo-gmail");
|
gmailButton = getE("mailgo-gmail");
|
||||||
outlookButton = document.getElementById("mailgo-outlook");
|
outlookButton = getE("mailgo-outlook");
|
||||||
openButton = document.getElementById("mailgo-open");
|
openButton = getE("mailgo-open");
|
||||||
copyButton = document.getElementById("mailgo-copy");
|
copyButton = getE("mailgo-copy");
|
||||||
|
|
||||||
titleEl.textContent = mail;
|
titleEl.textContent = mail;
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ mailgoCheckRender = event => {
|
|||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
// check if the id=mailgo exists in the body
|
// check if the id=mailgo exists in the body
|
||||||
if (!document.body.contains(document.getElementById("mailgo"))) return;
|
if (!document.body.contains(getE("mailgo"))) return;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
|
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
|
||||||
@ -293,7 +293,8 @@ mailgoCheckRender = event => {
|
|||||||
e.href.toLowerCase().startsWith(MAILTO) &&
|
e.href.toLowerCase().startsWith(MAILTO) &&
|
||||||
!e.classList.contains("no-mailgo")) ||
|
!e.classList.contains("no-mailgo")) ||
|
||||||
// second case: the href=#mailgo
|
// second case: the href=#mailgo
|
||||||
(e.href && e.href.toLowerCase() == "#mailgo") ||
|
// TODO FIX here
|
||||||
|
(e.href && e.href.toLowerCase() === "#mailgo") ||
|
||||||
//third case: the classList contains mailgo
|
//third case: the classList contains mailgo
|
||||||
e.classList.contains("mailgo")
|
e.classList.contains("mailgo")
|
||||||
) {
|
) {
|
||||||
@ -339,13 +340,16 @@ copyToClipboard = str => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// show the modal
|
// show the modal
|
||||||
showMailgo = () => (document.getElementById("mailgo").style.display = "flex");
|
showMailgo = () => (getE("mailgo").style.display = "flex");
|
||||||
|
|
||||||
// hide the modal
|
// hide the modal
|
||||||
hideMailgo = () => (document.getElementById("mailgo").style.display = "none");
|
hideMailgo = () => (getE("mailgo").style.display = "none");
|
||||||
|
|
||||||
// decrypt email
|
// decrypt email
|
||||||
mailToEncoded = encoded => (window.location.href = MAILTO + atob(encoded));
|
mailToEncoded = encoded => (window.location.href = MAILTO + atob(encoded));
|
||||||
|
|
||||||
// encode email
|
// encode email
|
||||||
encodeEmail = email => btoa(email);
|
encodeEmail = email => btoa(email);
|
||||||
|
|
||||||
|
// getE shorthand
|
||||||
|
getE = id => document.getElementById(id);
|
||||||
|
2
dist/mailgo.min.js
vendored
2
dist/mailgo.min.js
vendored
File diff suppressed because one or more lines are too long
@ -218,21 +218,21 @@ mailgoRender = mailgo => {
|
|||||||
// validate the email address
|
// validate the email address
|
||||||
if (!validateEmail(mail)) return;
|
if (!validateEmail(mail)) return;
|
||||||
|
|
||||||
titleEl = document.getElementById("mailgo-title");
|
titleEl = getE("mailgo-title");
|
||||||
detailsEl = document.getElementById("mailgo-details");
|
detailsEl = getE("mailgo-details");
|
||||||
ccEl = document.getElementById("mailgo-cc");
|
ccEl = getE("mailgo-cc");
|
||||||
ccValueEl = document.getElementById("mailgo-cc-value");
|
ccValueEl = getE("mailgo-cc-value");
|
||||||
bccEl = document.getElementById("mailgo-bcc");
|
bccEl = getE("mailgo-bcc");
|
||||||
bccValueEl = document.getElementById("mailgo-bcc-value");
|
bccValueEl = getE("mailgo-bcc-value");
|
||||||
subjectEl = document.getElementById("mailgo-subject");
|
subjectEl = getE("mailgo-subject");
|
||||||
subjectValueEl = document.getElementById("mailgo-subject-value");
|
subjectValueEl = getE("mailgo-subject-value");
|
||||||
bodyEl = document.getElementById("mailgo-body");
|
bodyEl = getE("mailgo-body");
|
||||||
bodyValueEl = document.getElementById("mailgo-body-value");
|
bodyValueEl = getE("mailgo-body-value");
|
||||||
|
|
||||||
gmailButton = document.getElementById("mailgo-gmail");
|
gmailButton = getE("mailgo-gmail");
|
||||||
outlookButton = document.getElementById("mailgo-outlook");
|
outlookButton = getE("mailgo-outlook");
|
||||||
openButton = document.getElementById("mailgo-open");
|
openButton = getE("mailgo-open");
|
||||||
copyButton = document.getElementById("mailgo-copy");
|
copyButton = getE("mailgo-copy");
|
||||||
|
|
||||||
titleEl.textContent = mail;
|
titleEl.textContent = mail;
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ mailgoCheckRender = event => {
|
|||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
// check if the id=mailgo exists in the body
|
// check if the id=mailgo exists in the body
|
||||||
if (!document.body.contains(document.getElementById("mailgo"))) return;
|
if (!document.body.contains(getE("mailgo"))) return;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
|
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
|
||||||
@ -340,13 +340,16 @@ copyToClipboard = str => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// show the modal
|
// show the modal
|
||||||
showMailgo = () => (document.getElementById("mailgo").style.display = "flex");
|
showMailgo = () => (getE("mailgo").style.display = "flex");
|
||||||
|
|
||||||
// hide the modal
|
// hide the modal
|
||||||
hideMailgo = () => (document.getElementById("mailgo").style.display = "none");
|
hideMailgo = () => (getE("mailgo").style.display = "none");
|
||||||
|
|
||||||
// decrypt email
|
// decrypt email
|
||||||
mailToEncoded = encoded => (window.location.href = MAILTO + atob(encoded));
|
mailToEncoded = encoded => (window.location.href = MAILTO + atob(encoded));
|
||||||
|
|
||||||
// encode email
|
// encode email
|
||||||
encodeEmail = email => btoa(email);
|
encodeEmail = email => btoa(email);
|
||||||
|
|
||||||
|
// getE shorthand
|
||||||
|
getE = id => document.getElementById(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user