Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (cookie == 1) {
- alert("Oi, você enviou uma mensagem a pouco tempo, em breve vamos te responder, ok?");
- return;
- }
- if (document.querySelector('.menu-help-box-form')) {
- document.querySelector('.menu-help-box-form').addEventListener('submit', function (event) {
- var cookie = getCookieValue('form_help_box');
- if (cookie == 1) {
- alert("Oi, você enviou uma mensagem a pouco tempo, em breve vamos te responder, ok?");
- return;
- }
- event.preventDefault();
- var formD = new FormData(this);
- var helpBObject = {};
- var con = {
- 0: "name",
- 1: "email",
- 2: "reason",
- 3: "message"
- };
- var numCont = 0;
- formD.forEach(function (element) {
- helpBObject[con[numCont]] = element;
- numCont++;
- });
- $.ajax({
- url: "/api/dataentities/HB/documents",
- type: "POST",
- timeout: 0,
- headers: {
- "Content-Type": "application/json",
- "Accept": "application/vnd.vtex.ds.v10+json"
- },
- data: JSON.stringify(helpBObject),
- success: function () {
- document.querySelector('.success-send-form-help').style.display = "flex";
- var d = new Date();
- d.setTime(d.getTime() + (1 * 24 * 60 * 60 * 1000));
- var expires = "expires=" + d.toUTCString();
- document.cookie = "form_help_box=1; " + expires + "; path=/";
- },
- error: function (error) {
- console.log("Erro Help Box: ", error);
- }
- });
- });
- document.querySelector('.cancel-send-form-help').addEventListener('click', function () {
- document.querySelector('.menu-help-box-form').style.display = "none";
- if (document.querySelector('.success-send-form-help')) {
- document.querySelector('.success-send-form-help').style.display = "none";
- }
- document.querySelector('.menu-help-box-ul').style.display = "block";
- });
- }
Add Comment
Please, Sign In to add comment