d2321
5/15/2020 - 4:10 PM

CF7 Helpers JS On Sent

  function getUrlParameter(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
    var results = regex.exec(location.href);
    return results === null
      ? ""
      : decodeURIComponent(results[1].replace(/\+/g, "    "));
  }

  document.addEventListener(
    "wpcf7mailsent",
    function (event) {
      //
      // if ("23" !== event.detail.contactFormId) {
      if (true) {
        // var url = window.location.href;
        // if (url.indexOf("?") > -1) {
        //   url += "&thanks=true";
        // } else {
        //   url += "?thanks=true";
        // }
        // window.location.href = url;
        if ($("#thanks_popup").length) {
          lity("#thanks_popup");
        }
      }

      //console.log(event.detail);
    },
    false
  );

  // var getThxGet = getUrlParameter("thanks");
  // if (getThxGet === "true") {
  //   if ($("#thanks_popup").length) {
  //     lity("#thanks_popup");
  //   }
  // }
  //