@alexsab-ru/scripts 0.8.4 → 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 +10 -5
- package/package.json +1 -1
package/lib/form.js
CHANGED
|
@@ -163,6 +163,10 @@ async function submitForm(form){
|
|
|
163
163
|
reachGoal("form_submit");
|
|
164
164
|
|
|
165
165
|
let formData = new FormData(form);
|
|
166
|
+
let sendMailCookie = props.sendMailCookie;
|
|
167
|
+
if(formData.get('dealer')) {
|
|
168
|
+
sendMailCookie += "_" + formData.get('dealer');
|
|
169
|
+
}
|
|
166
170
|
if(getCookie('fta')) {
|
|
167
171
|
formData.append("fta", true);
|
|
168
172
|
}
|
|
@@ -244,7 +248,7 @@ async function submitForm(form){
|
|
|
244
248
|
return;
|
|
245
249
|
} else {
|
|
246
250
|
reachGoal("form_success", formDataObj);
|
|
247
|
-
setCookie(
|
|
251
|
+
setCookie(sendMailCookie, true, {'domain': window.location.hostname,'path':'/','expires':600});
|
|
248
252
|
// Вызов callback при успехе
|
|
249
253
|
if (props.callback && typeof props.callback === 'function') {
|
|
250
254
|
props.callback(data);
|
|
@@ -257,7 +261,7 @@ async function submitForm(form){
|
|
|
257
261
|
.catch((error) => {
|
|
258
262
|
reachGoal("form_error");
|
|
259
263
|
console.error("Ошибка отправки данных формы: " + error);
|
|
260
|
-
deleteCookie(
|
|
264
|
+
deleteCookie(sendMailCookie);
|
|
261
265
|
// Вызов callback_error при ошибке
|
|
262
266
|
if (props.callback_error && typeof props.callback_error === 'function') {
|
|
263
267
|
props.callback_error(data);
|
|
@@ -271,10 +275,11 @@ async function submitForm(form){
|
|
|
271
275
|
|
|
272
276
|
async function sendForm(form) {
|
|
273
277
|
let formData = new FormData(form);
|
|
278
|
+
let sendMailCookie = props.sendMailCookie;
|
|
274
279
|
if(formData.get('dealer')) {
|
|
275
|
-
|
|
280
|
+
sendMailCookie += "_" + formData.get('dealer');
|
|
276
281
|
}
|
|
277
|
-
if (getCookie(
|
|
282
|
+
if (getCookie(sendMailCookie)) {
|
|
278
283
|
const confirmModal = document.getElementById('confirm-modal');
|
|
279
284
|
if (confirmModal) {
|
|
280
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>';
|
|
@@ -290,7 +295,7 @@ async function sendForm(form) {
|
|
|
290
295
|
// Закрываем модальное окно
|
|
291
296
|
confirmModal.classList.add("hidden");
|
|
292
297
|
// Удаляем куку
|
|
293
|
-
deleteCookie(
|
|
298
|
+
deleteCookie(sendMailCookie);
|
|
294
299
|
// Повторно отправляем форму
|
|
295
300
|
await submitForm(form);
|
|
296
301
|
return;
|