Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
4.3 kB
4
Indexable
Never
function passForm() {
    document.querySelector(".form-tool__contact > .form-tool__submit").addEventListener("click", function () {
        let e,
            o,
            t,
            r = "";
        var c = document.querySelector('select[name="location"]');
        "" != c.value && ((e = JSON.parse(c.value)), (o = e.country), (t = e.continent), (r = e.price)),
            document.body.contains(document.querySelector('input[name="form-language-email"]')) &&
            document.querySelectorAll(".email-relate").forEach(function (e) {
                e.value.split(",").includes(o) && (document.querySelector('input[name="form-language-email"]').value = e.getAttribute("data-email"));
            });
        var n = document.querySelector(".form-tool__range .form-tool__number input").value,
            l = document.querySelector('.form-tool__contact input[name="name"]').value,
            c = document.querySelector('.form-tool__contact input[name="email"]').value;
        let a = "",
            u;
        if (
            (document.querySelectorAll('.form-tool__left input[name="offer"]').forEach(function (e) {
                1 == e.checked && (a = document.querySelector('.form-tool__left input[name="offer"]:checked').value);
            }),
                "" != a && "" != o && "" != l && "" != c)
        )
            if (
                (document.querySelector(".form-tool__contact .form-tool__error.form-tool__error--fields").classList.remove("form-tool__error--visible"),
                    0 == document.querySelector('.form-tool__contact input[name="getintouch"]').checked)
            )
                document.querySelector(".form-tool__contact .form-tool__error.form-tool__error--consent").classList.add("form-tool__error--visible");
            else {
                if (
                    (document.querySelector(".form-tool__contact .form-tool__error.form-tool__error--consent").classList.remove("form-tool__error--visible"),
                        document.body.contains(document.querySelector(".form-tool .wpcf7")) &&
                        1 == document.querySelector('.form-tool__contact input[name="useemail"]').checked &&
                        (document.querySelector('.form-tool input[name="form-offer-2"]').value = "You have also consented to your email being used for marketing purposes such as newsletters."),
                        ["United States"].includes(o))
                ) {

                } else if (["Albania"].includes(o)) {
                }
                // if (n < 15)
                //     switch (a) {
                //         case "essential":
                //             u = "1";
                //             break;
                //         case "connected":
                //             u = "2";
                //             break;
                //         case "complete":
                //             u = "3";
                //     }

                if (document.body.contains(document.querySelector(".form-tool .wpcf7"))) {
                    (document.querySelector('.form-tool input[name="form-name"]').value = l),
                        (document.querySelector('.form-tool input[name="form-email"]').value = c),
                        (document.querySelector('.form-tool input[name="form-offer"]').value = u),
                        (document.querySelector('.form-tool input[name="math-quiz"]').value = "60"),
                        document.querySelector(".form-tool .wpcf7 .wpcf7-submit").click();
                    let e = document.querySelector(".form-tool .wpcf7");
                    e.addEventListener(
                        "wpcf7submit",
                        function (e) {
                            document.querySelector(".form-tool .form-tool__submit").setAttribute("disabled", "disabled"), document.querySelector(".form-tool").classList.add("form-tool--sending");
                        },
                        !1
                    );
                } else console.log("Success");
            }
        else document.querySelector(".form-tool__contact .form-tool__error.form-tool__error--fields").classList.add("form-tool__error--visible");
    });
}