henrydagobit

aguiascriptmain

Dec 13th, 2019
1,024
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.addEventListener('load', function () {
  2.     if(window.innerWidth > 767) {
  3.         document.getElementsByClassName("logo-medium")[0].innerHTML += "<a style='font-size: 24px;'>Águia Tracking Service</a>"
  4.     }else{
  5.         document.getElementsByClassName("logo-medium")[0].innerHTML += "<a style='font-size: 18px;'>Águia TS</a>"
  6.     }  
  7.  
  8.     if(window.location.pathname == "/contato"){
  9.         document.getElementById("fieldSubject").parentNode.innerHTML =
  10. `
  11.  <label>Assunto</label>
  12. <select class="form-control" id="fieldSubject" style="border: 1px solid #dde1e5 !important;">
  13.   <option value="orcamento">Orçamento</option>  
  14.   <option value="suporte">Suporte técnico</option>  
  15.   <option value="emprego">Oportunidade de Emprego</option>
  16.   <option value="reclamacao">Reclamação</option>
  17.   <option value="outros">Outros</option>
  18. </select>
  19. `;
  20.  
  21. document.getElementsByClassName("button submit-button button-lg undefined button-dynamic-buttons kv-button-instant-edit button-secondary")[0].onclick = function(){
  22.     var _nome = document.getElementById('fieldFirstName').value;
  23.     var _email = document.getElementById('fieldEmail').value;
  24.     var _assunto = document.getElementById('fieldSubject').value;
  25.     var _telefone = document.getElementById('fieldPhone').value;
  26.     var _message = document.getElementById('fieldMessage').value;
  27.  
  28.     if(_nome != "" && _email != "" && _email.indexOf("@") > 0 && _assunto != "" && _telefone != "" && _message != ""){
  29.         var xmlhttp = new XMLHttpRequest();
  30.         xmlhttp.open("POST", "https://us-central1-dagomail.cloudfunctions.net/enviarEmail");
  31.         xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
  32.  
  33.         xmlhttp.onreadystatechange = function() {//Call a function when the state changes.
  34.             if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  35.                 document.getElementById("contact-form").innerHTML = `<div style="height: 200px; text-align: center;">
  36.     <p style="font-size: 24px;">Mensagem enviada!</p>
  37.     <p style="font-size: 18px; font-size: 18px; max-width: 500px; min-width: 300px; text-align: center; margin: auto; width: 50%; border: 3px solid #f7bc35; padding: 10px;">Sua mensagem foi enviada com sucesso. Esperamos responder em até 24 horas. Você também pode nos contatar através dos nossos e-mails e telefones. Os links estão logo abaixo.</p>
  38. </div>`
  39.             }
  40.         }
  41.  
  42.         xmlhttp.send(JSON.stringify(
  43.         {
  44.             "nome": _nome,
  45.             "email": _email,
  46.             "assunto": _assunto,
  47.             "telefone": _telefone,
  48.             "message": _message,
  49.         }
  50.         ));
  51.     }
  52. }
  53.  
  54. setTimeout(function(){
  55.     if(document.getElementsByClassName("captcha-field-wrapper")[0]){
  56.         document.getElementsByClassName("captcha-field-wrapper")[0].style.visibility = "hidden";
  57.         document.getElementsByClassName("captcha-field-wrapper")[0].style.height = "0";
  58.     }
  59. },10);
  60.  
  61. document.getElementsByClassName("fieldSubscribe-container")[0].innerHTML = ""
  62.     }
  63.  
  64.    
  65. });
Add Comment
Please, Sign In to add comment