@alexsab-ru/scripts 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/form.js +8 -6
- package/package.json +1 -1
package/lib/form.js
CHANGED
|
@@ -163,8 +163,9 @@ async function submitForm(form){
|
|
|
163
163
|
reachGoal("form_submit");
|
|
164
164
|
|
|
165
165
|
let formData = new FormData(form);
|
|
166
|
+
let sendMailCookie = props.sendMailCookie;
|
|
166
167
|
if(formData.get('dealer')) {
|
|
167
|
-
|
|
168
|
+
sendMailCookie += "_" + formData.get('dealer');
|
|
168
169
|
}
|
|
169
170
|
if(getCookie('fta')) {
|
|
170
171
|
formData.append("fta", true);
|
|
@@ -247,7 +248,7 @@ async function submitForm(form){
|
|
|
247
248
|
return;
|
|
248
249
|
} else {
|
|
249
250
|
reachGoal("form_success", formDataObj);
|
|
250
|
-
setCookie(
|
|
251
|
+
setCookie(sendMailCookie, true, {'domain': window.location.hostname,'path':'/','expires':600});
|
|
251
252
|
// Вызов callback при успехе
|
|
252
253
|
if (props.callback && typeof props.callback === 'function') {
|
|
253
254
|
props.callback(data);
|
|
@@ -260,7 +261,7 @@ async function submitForm(form){
|
|
|
260
261
|
.catch((error) => {
|
|
261
262
|
reachGoal("form_error");
|
|
262
263
|
console.error("Ошибка отправки данных формы: " + error);
|
|
263
|
-
deleteCookie(
|
|
264
|
+
deleteCookie(sendMailCookie);
|
|
264
265
|
// Вызов callback_error при ошибке
|
|
265
266
|
if (props.callback_error && typeof props.callback_error === 'function') {
|
|
266
267
|
props.callback_error(data);
|
|
@@ -274,10 +275,11 @@ async function submitForm(form){
|
|
|
274
275
|
|
|
275
276
|
async function sendForm(form) {
|
|
276
277
|
let formData = new FormData(form);
|
|
278
|
+
let sendMailCookie = props.sendMailCookie;
|
|
277
279
|
if(formData.get('dealer')) {
|
|
278
|
-
|
|
280
|
+
sendMailCookie += "_" + formData.get('dealer');
|
|
279
281
|
}
|
|
280
|
-
if (getCookie(
|
|
282
|
+
if (getCookie(sendMailCookie)) {
|
|
281
283
|
const confirmModal = document.getElementById('confirm-modal');
|
|
282
284
|
if (confirmModal) {
|
|
283
285
|
confirmModal.querySelector('p').innerHTML = props.confirmModalText || '<span style="color: tomato; font-weight: bold">ПЕРЕДАЙ ТЕКСТ В ОБЪЕКТЕ <br><pre style="color: black; font-weight: 400">props = {confirmModalText: <i>"text"</i>}</pre></span>';
|
|
@@ -293,7 +295,7 @@ async function sendForm(form) {
|
|
|
293
295
|
// Закрываем модальное окно
|
|
294
296
|
confirmModal.classList.add("hidden");
|
|
295
297
|
// Удаляем куку
|
|
296
|
-
deleteCookie(
|
|
298
|
+
deleteCookie(sendMailCookie);
|
|
297
299
|
// Повторно отправляем форму
|
|
298
300
|
await submitForm(form);
|
|
299
301
|
return;
|