aggiunto listener al load
This commit is contained in:
parent
80aa99c919
commit
a1ff8f5fdc
@ -81,19 +81,20 @@ let styles = `
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// ottengo tutti i mailto contenuti nella pagina
|
function mailgoInit() {
|
||||||
let mailgos = document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)');
|
// ottengo tutti i mailto contenuti nella pagina
|
||||||
|
let mailgos = document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)');
|
||||||
|
|
||||||
// CSS
|
// CSS
|
||||||
let styleSheet = document.createElement("style");
|
let styleSheet = document.createElement("style");
|
||||||
styleSheet.type = "text/css";
|
styleSheet.type = "text/css";
|
||||||
styleSheet.innerText = styles;
|
styleSheet.innerText = styles;
|
||||||
document.head.appendChild(styleSheet);
|
document.head.appendChild(styleSheet);
|
||||||
|
|
||||||
console.log("mailgo is WIP!");
|
console.log("mailgo is WIP!");
|
||||||
|
|
||||||
// attivo mailgo su tutti gli elementi
|
// attivo mailgo su tutti gli elementi
|
||||||
mailgos.forEach(function(mailgo, index) {
|
mailgos.forEach(function(mailgo, index) {
|
||||||
let mail = mailgo.href
|
let mail = mailgo.href
|
||||||
.split("?")[0]
|
.split("?")[0]
|
||||||
.split("mailto:")[1]
|
.split("mailto:")[1]
|
||||||
@ -136,7 +137,8 @@ mailgos.forEach(function(mailgo, index) {
|
|||||||
|
|
||||||
// Gmail
|
// Gmail
|
||||||
let gmail = document.createElement("a");
|
let gmail = document.createElement("a");
|
||||||
gmail.href = "https://mail.google.com/mail?extsrc=mailto&url=" + mailgo.href;
|
gmail.href =
|
||||||
|
"https://mail.google.com/mail?extsrc=mailto&url=" + mailgo.href;
|
||||||
gmail.classList.add("mailgo-open");
|
gmail.classList.add("mailgo-open");
|
||||||
gmail.classList.add("gmail");
|
gmail.classList.add("gmail");
|
||||||
let gmailContent = document.createTextNode("open in ");
|
let gmailContent = document.createTextNode("open in ");
|
||||||
@ -223,7 +225,10 @@ mailgos.forEach(function(mailgo, index) {
|
|||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("load", mailgoInit);
|
||||||
|
|
||||||
function validateEmail(email) {
|
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,}))$/;
|
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,}))$/;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user