aggiunta funzionalità di encrypt email (da testare)
This commit is contained in:
parent
7e2787ad32
commit
5ed27a17e3
20
README.md
20
README.md
@ -17,15 +17,6 @@ mailgo will substitute all the `mailto:` links with the **mailgo modal**, in les
|
||||
|
||||
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>
|
||||
...
|
||||
@ -33,21 +24,12 @@ or
|
||||
</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`
|
||||
|
||||
```
|
||||
<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>
|
||||
```
|
||||
|
||||
|
@ -156,7 +156,17 @@ mailgoInit = () => {
|
||||
|
||||
// open default
|
||||
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-weight-500");
|
||||
let openContent = document.createTextNode("open");
|
||||
@ -248,3 +258,14 @@ copyToClipboard = str => {
|
||||
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user