PageSourceSearch

https://i-kazan.com/mailer/mailer.js

js i-kazan.com collected 2026-10-04 13:00:11 UTC 5,547 bytes, 147 lines download raw bytes

1document.addEventListener("DOMContentLoaded", () => {
2  const forms = document.querySelectorAll(".php-mailer");
3
4  if (forms.length > 0) {
5    forms.forEach((form) => {
6      form.addEventListener("submit", async (e) => {
7        e.preventDefault();
8
9        const name = form.elements.name?.value.trim() || "";
10        const email = form.elements.email?.value.trim() || "";
11        const phone = form.elements.phone?.value.trim() || "";
12        const message = form.elements.message?.value.trim() || "";
13
14        const formData = new FormData();
15        formData.append("name", name);
16        formData.append("email", email);
17        formData.append("phone", phone);
18        formData.append("message", message);
19
20        try {
21          const response = await fetch("mailer/send_email.php", {
22            method: "POST",
23            body: formData,
24          });
25
26          const text = await response.text();
27
28          console.log("📥 Ответ сервера:", text);
29
30          if (response.ok && text.trim() === "ok") {
31            alert("✅ Заявка успешно отправлена!");
32            form.reset();
33          } else {
34            alert("❌ Ошибка при отправке заявки: " + text);
35          }
36        } catch (error) {
37          console.error("🚨 Ошибка при отправке запроса:", error);
38          alert("⚠ Произошла ошибка при отправке заявки.");
39        }
40      });
41    });
42  }
43
44  const phoneInputs = document.querySelectorAll('input[type="tel"]');
45
46  phoneInputs.forEach(function (input) {
47    input.addEventListener("input", onPhoneInput);
48    input.addEventListener("focus", onPhoneInput);
49    input.addEventListener("blur", onPhoneBlur);
50
51    function onPhoneInput() {
52      let x = input.value.replace(/\D/g, "").substring(1);
53      let formatted = "+7";
54
55      if (x.length > 0) formatted += " (" + x.substring(0, 3);
56      if (x.length >= 4) formatted += ") " + x.substring(3, 6);
57      if (x.length >= 7) formatted += "-" + x.substring(6, 8);
58      if (x.length >= 9) formatted += "-" + x.substring(8, 10);
59
60      input.value = formatted;
61    }
62
63    function onPhoneBlur() {
64      if (input.value.replace(/\D/g, "").length < 11) {
65        input.value = "";
66      }
67    }
68  });
69});
70
71
72
73
74// document.addEventListener("DOMContentLoaded", () => {
75//   const siteKey = "6LeW7AcsAAAAAFYK-fFWzbEF55yfZ-_P_aofs9Dk";
76//   const forms = document.querySelectorAll(".php-mailer");
77
78//   if (forms.length > 0) {
79//     forms.forEach((form) => {
80//       form.addEventListener("submit", async (e) => {
81//         e.preventDefault();
82
83//         const name = form.elements.name?.value.trim() || "";
84//         const email = form.elements.email?.value.trim() || "";
85//         const phone = form.elements.phone?.value.trim() || "";
86//         const message = form.elements.message?.value.trim() || "";
87
88//         grecaptcha.ready(() => {
89//           grecaptcha.execute(siteKey, { action: "submit" }).then(async (token) => {
90//             const formData = new FormData();
91//             formData.append("name", name);
92//             formData.append("email", email);
93//             formData.append("phone", phone);
94//             formData.append("message", message);
95//             formData.append("recaptcha_token", token); // 👈 ИСПРАВЛЕНО: было "token"
96
97//             try {
98//               const response = await fetch("mailer/send_email.php", {
99//                 method: "POST",
100//                 body: formData,
101//               });
102
103//               const text = await response.text();
104//               console.log("📥 Ответ сервера:", text);
105
106//               if (response.ok && text === 'ok') { // 👈 ИСПРАВЛЕНО: проверяем текст ответа
107//                 alert("✅ Заявка успешно отправлена!");
108//                 form.reset();
109//               } else {
110//                 alert("❌ Ошибка при отправке заявки: " + text);
111//               }
112//             } catch (error) {
113//               console.error("🚨 Ошибка при отправке запроса:", error);
114//               alert("⚠ Произошла ошибка при отправке заявки.");
115//             }
116//           });
117//         });
118//       });
119//     });
120//   } // 👈 ЗАКРЫВАЮЩАЯ скобка для if (forms.length > 0)
121
122//   const phoneInputs = document.querySelectorAll('input[type="tel"]');
123  
124//   phoneInputs.forEach(function (input) {
125//     input.addEventListener("input", onPhoneInput);
126//     input.addEventListener("focus", onPhoneInput);
127//     input.addEventListener("blur", onPhoneBlur);
128
129//     function onPhoneInput(e) {
130//       let x = input.value.replace(/\D/g, "").substring(1);
131//       let formatted = "+7";
132
133//       if (x.length > 0) formatted += " (" + x.substring(0, 3);
134//       if (x.length >= 4) formatted += ") " + x.substring(3, 6);
135//       if (x.length >= 7) formatted += "-" + x.substring(6, 8);
136//       if (x.length >= 9) formatted += "-" + x.substring(8, 10);
137
138//       input.value = formatted;
139//     }
140
141//     function onPhoneBlur() {
142//       if (input.value.replace(/\D/g, "").length < 11) {
143//         input.value = "";
144//       }
145//     }
146//   });
147// }); // 👈 ЗАКРЫВАЮЩАЯ скобка для DOMContentLoaded

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.