aggiunta funzionalità di encrypt email (da testare)

This commit is contained in:
Matteo Manzinello 2019-05-09 09:16:31 +02:00
parent 7e2787ad32
commit 5ed27a17e3
2 changed files with 23 additions and 20 deletions

View File

@ -17,15 +17,6 @@ mailgo will substitute all the `mailto:` links with the **mailgo modal**, in les
add at the end of the `<body>` add at the end of the `<body>`
```
<body>
...
<script src="https://cdn.jsdelivr.net/npm/mailgo@latest/dist/mailgo.min.js"></script>
</body>
```
or
``` ```
<body> <body>
... ...
@ -33,21 +24,12 @@ or
</body> </body>
``` ```
or download the script <a download href="https://unpkg.com/mailgo@latest/dist/mailgo.min.js">here</a> and
```
<body>
...
<script src="path/to/mailgo/mailgo.min.js"></script>
</body>
```
you can also import mailgo in `<head>` using `defer` you can also import mailgo in `<head>` using `defer`
``` ```
<head> <head>
... ...
<script src="https://cdn.jsdelivr.net/npm/mailgo@latest/dist/mailgo.min.js" defer></script> <script src="https://unpkg.com/mailgo@latest/dist/mailgo.min.js" defer></script>
</head> </head>
``` ```

View File

@ -156,7 +156,17 @@ mailgoInit = () => {
// open default // open default
let open = document.createElement("a"); let open = document.createElement("a");
open.href = mailtoHref;
open.href = "#mailgo-open";
let encEmail = encryptEmail(mail);
open.addEventListener(
"click",
() => {
mailToEncoded(encEmail);
},
false
);
open.classList.add("mailgo-open"); open.classList.add("mailgo-open");
open.classList.add("mailgo-weight-500"); open.classList.add("mailgo-weight-500");
let openContent = document.createTextNode("open"); let openContent = document.createTextNode("open");
@ -248,3 +258,14 @@ copyToClipboard = str => {
document.getSelection().addRange(selected); document.getSelection().addRange(selected);
} }
}; };
// decrypt email
function mailToEncoded(encoded) {
var address = atob(encoded);
window.location.href = "mailto:" + address;
}
// encrypt email
function encryptEmail(email) {
return btoa(email);
}