| Server IP : 20.75.53.88 / Your IP : 216.73.217.72 [ Web Server : Apache System : Linux VMRALP-3 4.4.0-256-generic #290~14.04.1-Ubuntu SMP Thu Jun 20 09:24:50 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29+esm15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Domains : 3 Domains MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/portais/controller/js/modules/ |
Upload File : |
const base_URL = "https://apiemail.gtcontroller.com.br"
export default function initSendCurriculo() {
const form = document.querySelector('.form-curriculo');
const inputs = form.querySelectorAll('.campo');
const modalEnvio = document.querySelectorAll('.modal-form');
const modalSucess = document.querySelector('.modal-sucess');
const modalErro = document.querySelector('.modal-erro');
const closeModal = document.querySelectorAll('.close-modal');
function getCookie(nome) {
var nomeCookie = nome + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nomeCookie) == 0) return c.substring(nomeCookie.length,c.length);
}
return null;
}
function getDataForm() {
const data = new FormData(form);
const file = document.getElementById('Curriculo');
data.append('file', file.files);
return data;
}
function handleSubmitCurriculo(event) {
event.preventDefault();
const btnForm = form.querySelector('.btn-curriculo');
const btnEnvio = document.querySelector('form .btn-envio');
if (getCookie("_ga")) {
btnForm.style.display = 'none';
btnEnvio.classList.toggle('active');
fetch(`${base_URL}/sendCurriculo`, { method: "POST", body: getDataForm() })
.then(res => {
if (res.status === 200) return res.json();
throw new Error('the email was not sent');
})
.then(res => {
modalSucess.classList.add('active');
setInterval(() => modalSucess.classList.remove('active'), 3500)
})
.catch(error => {
modalErro.classList.add('active')
setInterval(() => modalErro.classList.remove('active'), 3500)
})
.finally(() => {
btnForm.style.display = 'block';
btnEnvio.classList.toggle('active');
inputs.forEach(item => item.value = " ");
})
}
}
closeModal.forEach((item) => {
item.addEventListener('click', () => {
modalEnvio.forEach((item) => {
item.classList.remove('active');
})
})
})
form.addEventListener('submit', handleSubmitCurriculo);
}