const instead of let
This commit is contained in:
parent
fde889cc4b
commit
51eaecbf9f
@ -12,7 +12,7 @@ document.head.appendChild(mailgoCSS);
|
|||||||
* mailgoInit
|
* mailgoInit
|
||||||
* the function that creates the mailgo element in DOM
|
* the function that creates the mailgo element in DOM
|
||||||
*/
|
*/
|
||||||
let mailgoInit = () => {
|
const mailgoInit = () => {
|
||||||
// modal
|
// modal
|
||||||
let modal = document.createElement("div");
|
let modal = document.createElement("div");
|
||||||
modal.id = "mailgo";
|
modal.id = "mailgo";
|
||||||
@ -164,7 +164,7 @@ let mailgoInit = () => {
|
|||||||
* mailgoRender
|
* mailgoRender
|
||||||
* function to render a single mailgo
|
* function to render a single mailgo
|
||||||
*/
|
*/
|
||||||
let mailgoRender = mailgo => {
|
const mailgoRender = mailgo => {
|
||||||
let mail = "",
|
let mail = "",
|
||||||
url = "",
|
url = "",
|
||||||
mailtoHref = "",
|
mailtoHref = "",
|
||||||
@ -308,7 +308,7 @@ let mailgoRender = mailgo => {
|
|||||||
* 'a[href^="mailto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo'
|
* 'a[href^="mailto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo'
|
||||||
* ); and the new a[mailgo]
|
* ); and the new a[mailgo]
|
||||||
*/
|
*/
|
||||||
let mailgoCheckRender = event => {
|
const mailgoCheckRender = event => {
|
||||||
// the target element
|
// the target element
|
||||||
let e = event.target;
|
let e = event.target;
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ let mailgoCheckRender = event => {
|
|||||||
* mailgoKeydown
|
* mailgoKeydown
|
||||||
* function to manage the keydown event when the modal is showing
|
* function to manage the keydown event when the modal is showing
|
||||||
*/
|
*/
|
||||||
let mailgoKeydown = event => {
|
const mailgoKeydown = event => {
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
case 27:
|
case 27:
|
||||||
// Escape
|
// Escape
|
||||||
@ -358,13 +358,13 @@ document.addEventListener("DOMContentLoaded", mailgoInit, false);
|
|||||||
document.body.addEventListener("click", mailgoCheckRender, false);
|
document.body.addEventListener("click", mailgoCheckRender, false);
|
||||||
|
|
||||||
// validate the email with regex
|
// validate the email with regex
|
||||||
let validateEmail = email => {
|
const validateEmail = email => {
|
||||||
let 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,}))$/;
|
let 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,}))$/;
|
||||||
return re.test(email);
|
return re.test(email);
|
||||||
};
|
};
|
||||||
|
|
||||||
// copy of a string
|
// copy of a string
|
||||||
let copyToClipboard = str => {
|
const copyToClipboard = str => {
|
||||||
let el = document.createElement("textarea");
|
let el = document.createElement("textarea");
|
||||||
el.value = str;
|
el.value = str;
|
||||||
el.setAttribute("readonly", "");
|
el.setAttribute("readonly", "");
|
||||||
@ -385,23 +385,25 @@ let copyToClipboard = str => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// show the modal
|
// show the modal
|
||||||
let showMailgo = () => {
|
const showMailgo = () => {
|
||||||
getE("mailgo").style.display = "flex";
|
getE("mailgo").style.display = "flex";
|
||||||
// add mailgoKeydown
|
// add mailgoKeydown
|
||||||
document.body.addEventListener("keydown", mailgoKeydown, false);
|
document.body.addEventListener("keydown", mailgoKeydown, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
// hide the modal
|
// hide the modal
|
||||||
let hideMailgo = () => {
|
const hideMailgo = () => {
|
||||||
getE("mailgo").style.display = "none";
|
getE("mailgo").style.display = "none";
|
||||||
// remove mailgoKeydown
|
// remove mailgoKeydown
|
||||||
document.body.removeEventListener("keydown", mailgoKeydown, false);
|
document.body.removeEventListener("keydown", mailgoKeydown, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
// decrypt email
|
// decrypt email
|
||||||
let mailToEncoded = encoded => (window.location.href = MAILTO + atob(encoded));
|
const mailToEncoded = encoded =>
|
||||||
|
(window.location.href = MAILTO + atob(encoded));
|
||||||
|
|
||||||
// encode email
|
// encode email
|
||||||
let encodeEmail = email => btoa(email);
|
const encodeEmail = email => btoa(email);
|
||||||
|
|
||||||
// getE shorthand
|
// getE shorthand
|
||||||
let getE = id => document.getElementById(id);
|
const getE = id => document.getElementById(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user