Skip to content

Commit e7a7647

Browse files
committed
feat: 🎉 add project
0 parents  commit e7a7647

31 files changed

+37828
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
assets/plugins/bootstrap/scss
2+
assets/plugins/bootstrap/custom-scss
3+
assets/scss

app.js

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { generateAleatoryEmails, generateCustomEmails, generateHumanEmails } from "./modules/generateEmail.js";
2+
3+
const d = document;
4+
const $ = (e) => d.querySelector(e);
5+
const $a = (e) => d.querySelectorAll(e);
6+
7+
export const app = (e) => {
8+
let path = window.location.pathname.split(".")[0];
9+
if (path === "/email-generator/index" || path === "/email-generator/") {
10+
document.title = "Generador Correos";
11+
12+
if ($("#aleatory_email").checked) {
13+
$("#form-container").insertAdjacentHTML("beforeend", "<aleatory-email-component></aleatory-email-component>");
14+
}
15+
16+
d.addEventListener("submit", async (e) => {
17+
// ALEATORY EMAILS
18+
if (e.target.matches("#generate-aleatory-emails")) {
19+
e.preventDefault();
20+
$("#email-response").innerHTML = "";
21+
let data = Object.fromEntries(new FormData(e.target));
22+
if (!data.length_email && !isNaN(data.length_email)) {
23+
alert("Longitud del email es requerido");
24+
} else if (!data.quantity_email && !isNaN(data.length_email)) {
25+
alert("Cantidad es requerida");
26+
} else {
27+
if (!(Number(data.length_email) > 3 && Number(data.length_email) <= 40)) {
28+
alert("Longitud no valida");
29+
} else if (!(Number(data.quantity_email) <= 100)) {
30+
alert("Cantidad no valida");
31+
} else if (!(/^[a-z0-9.-]+\.[a-z]{2,6}$/.test(data.domain_email))) {
32+
alert("Dominio invalido, no agregues @");
33+
} else {
34+
let correos = generateAleatoryEmails(data);
35+
correos.forEach((e) => {
36+
$("#email-response").insertAdjacentHTML("beforeend", `<li class="list-group-item">${e}</li>`);
37+
})
38+
}
39+
}
40+
}
41+
42+
// HUMAN EMAILS
43+
if (e.target.matches("#generate-human-emails")) {
44+
e.preventDefault();
45+
$("#email-response").innerHTML = "";
46+
let data = Object.fromEntries(new FormData(e.target));
47+
if (!data.quantity_email && !isNaN(data.length_email)) {
48+
alert("Cantidad es requerida");
49+
} else {
50+
if (!(Number(data.quantity_email) <= 100)) {
51+
alert("Cantidad no valida");
52+
} else {
53+
let correos = await generateHumanEmails(data);
54+
correos.forEach((e) => {
55+
$("#email-response").insertAdjacentHTML("beforeend", `<li class="list-group-item">${e}</li>`);
56+
})
57+
}
58+
}
59+
}
60+
61+
// CUSTOM EMAILS
62+
if (e.target.matches("#generate-custom-emails")) {
63+
e.preventDefault();
64+
$("#email-response").innerHTML = "";
65+
let data = Object.fromEntries(new FormData(e.target));
66+
if (!data.quantity_email && !isNaN(data.length_email)) {
67+
alert("Cantidad es requerida");
68+
} else {
69+
if (!(/^[a-zA-Z0-9.]+$/.test(data.user_email))) {
70+
alert("Usuario email no es valido");
71+
} else if (!(/^[a-z0-9.-]+\.[a-z]{2,6}$/.test(data.domain_email))) {
72+
alert("Dominio invalido, no agregues @");
73+
} else if (!(Number(data.quantity_email) <= 100)) {
74+
alert("Cantidad no valida");
75+
} else {
76+
let correos = generateCustomEmails(data);
77+
correos.forEach((e) => {
78+
$("#email-response").insertAdjacentHTML("beforeend", `<li class="list-group-item">${e}</li>`);
79+
})
80+
}
81+
}
82+
}
83+
84+
})
85+
86+
d.addEventListener("input", (e) => {
87+
if (e.target.matches("[name='type_email']")) {
88+
$("#form-container").innerHTML = "";
89+
$("#email-response").innerHTML = "";
90+
91+
if (e.target.matches("#aleatory_email")) {
92+
$("#form-container").insertAdjacentHTML("beforeend", "<aleatory-email-component></aleatory-email-component>")
93+
}
94+
if (e.target.matches("#human_email")) {
95+
$("#form-container").insertAdjacentHTML("beforeend", "<human-email-component></human-email-component>")
96+
}
97+
if (e.target.matches("#custom_email")) {
98+
$("#form-container").insertAdjacentHTML("beforeend", "<custom-email-component></custom-email-component>")
99+
}
100+
101+
}
102+
})
103+
104+
d.addEventListener("click", (e) => {
105+
if (e.target.matches("#settings input[type='checkbox']")) {
106+
let checkSelected = [...$a("#settings input[type='checkbox']")].filter((checkbox) => checkbox.checked);
107+
if (checkSelected.length === 0) {
108+
e.target.checked = true;
109+
}
110+
}
111+
112+
if (e.target.matches("#copy-emails, #copy-emails *")) {
113+
const elementosLi = $a('li');
114+
let contenidoCopiado = '';
115+
116+
for (let i = 0; i < elementosLi.length; i++) {
117+
contenidoCopiado += elementosLi[i].textContent + '\n';
118+
}
119+
120+
const temp = document.createElement('textarea');
121+
temp.value = contenidoCopiado;
122+
document.body.appendChild(temp);
123+
temp.select();
124+
document.execCommand('copy');
125+
document.body.removeChild(temp);
126+
}
127+
})
128+
}
129+
130+
}
131+

assets/css/global.min.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600&display=swap");
2+
body {
3+
background-color: #012F3D;
4+
color: #fff;
5+
font-family: "Poppins", sans-serif;
6+
}
7+
8+
footer {
9+
background-color: #012F3D;
10+
margin: 0;
11+
padding: 0;
12+
}
13+
14+
input {
15+
border: none;
16+
border-radius: 2px;
17+
padding: 0.2rem 0.5rem;
18+
}
19+
20+
#form-container {
21+
margin: auto;
22+
max-width: 500px;
23+
}
24+
25+
.type-emails {
26+
padding: 2rem 0rem;
27+
width: 100%;
28+
}
29+
30+
.copyright a {
31+
text-decoration: none;
32+
color: #fff;
33+
font-weight: 700;
34+
}/*# sourceMappingURL=global.min.css.map */

assets/css/global.min.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)