PageSourceSearch

https://elpulqui.com/resources/scripts/clients/form_cv.js

js elpulqui.com collected 2026-10-09 05:14:42 UTC 2,531 bytes, 78 lines download raw bytes

1document.addEventListener("DOMContentLoaded", () => {
2  const form = document.getElementById("jobApplicationForm");
3  const fileInput = document.getElementById("cvFile");
4  const fileLabel = document.getElementById("cvLabel");
5  const submitButton = document.getElementById("submitButtonFormCv");
6  let loading = false;
7
8  // Cambia el estilo del label cuando se selecciona un archivo
9  fileInput.addEventListener("change", () => {
10    if (fileInput.files.length > 0) {
11      fileLabel.textContent = `OK`;
12      fileLabel.style.backgroundColor = "#28a745"; // Cambia el color del label
13    } else {
14      fileLabel.textContent = "CV";
15      fileLabel.style.backgroundColor = "#007BFF"; // Color original
16    }
17  });
18
19  // Manejo del envío del formulario
20  form.addEventListener("submit", async (event) => {
21    event.preventDefault();
22    if (loading) return;
23
24    const email = document.getElementById("email").value;
25    const fileInput = document.getElementById("cvFile");
26    const file = fileInput.files[0];
27
28    if (!file) {
29      alert("Por favor, selecciona un archivo.");
30      return;
31    }
32
33    // Convertir el archivo a base64
34    const reader = new FileReader();
35    reader.onload = async (e) => {
36      const fileContent = e.target.result.split(",")[1]; // Base64 del archivo
37
38      // Enviar datos al backend
39      try {
40        submitButton.textContent = "Enviando...";
41        submitButton.disabled = true;
42        loading = true;
43
44        const response = await fetch(
45          //"http://localhost:3001/api/web/send-email",
46          "https://elpulqui.progresodigital.net/api/web/send-email",
47          {
48            method: "POST",
49            headers: { "Content-Type": "application/json" },
50            body: JSON.stringify({
51              email,
52              file: fileContent,
53              filename: file.name,
54            }),
55          }
56        );
57
58        const data = await response.json();
59        if (response.ok) {
60          alert(data.message); // Mostrar éxito
61          form.reset(); // Limpiar el formulario
62          fileLabel.textContent = "CV";
63          fileLabel.style.backgroundColor = "#007BFF";
64          submitButton.textContent = "Enviar";
65        } else {
66          alert(data.error); // Mostrar error
67        }
68        submitButton.disabled = false;
69        loading = false;
70      } catch (err) {
71        console.error("Error:", err);
72        alert("Hubo un problema al enviar el correo.");
73      }
74    };
75
76    reader.readAsDataURL(file); // Leer el archivo como base64
77  });
78});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.