https://salesdoubler.pro/wp-content/themes/salesdoubler/js-necessa…/FormServices.class.js?rnd=529202
1class FormServices { 2 3 constructor() { 4 this.sitekey = "6Lc8vlwUAAAAAJX9AUX8SN5UqHSUZ9FMTXeQ7MFq"; 5 this.sitekeyV3 = "6Le396QrAAAAAJGOotGOyXd7IYkv6H4aKtBRyrid"; 6 this.analyticsURL = "https://salesdoubler.pro/wp-content/themes/salesdoubler/forms/analytics.php"; 7 this.sendformsURL = "https://salesdoubler.pro/wp-content/themes/salesdoubler/forms/sendforms.php"; 8 } 9 10 11 12 13 // Google reCAPTCHA v2 14 verifyCallback = (response) => { 15 if (grecaptcha.getResponse()) { 16 $("#gCaptchaValidate").val("true"); 17 $("button[type='submit']").click(); 18 } 19 }; 20 21 onloadCallback = () => { 22 grecaptcha.render("sendform", { 23 sitekey: "6Lc8vlwUAAAAAJX9AUX8SN5UqHSUZ9FMTXeQ7MFq", 24 callback: this.verifyCallback, 25 theme: "dark", 26 }); 27 }; 28 29 30 // Google reCAPTCHA v3 31 getCaptchaToken(id) { 32 return new Promise((resolve, reject) => { 33 if ($("#" + id).length > 0) { 34 grecaptcha.ready(function () { 35 grecaptcha.execute("6Le396QrAAAAAJGOotGOyXd7IYkv6H4aKtBRyrid", { action: "form" }) 36 .then(function (token) { 37 $("#" + id).val(token); 38 resolve(token); // Ñокен ÑÑпеÑно полÑÑен 39 }) 40 .catch(reject); // на ÑлÑÑай оÑибки 41 }); 42 } else { 43 reject(new Error("Element not found: #" + id)); 44 } 45 }); 46 } 47 48 49 50 51 /** 52 * Send analytics data to api (form Contact) 53 * @see SDD-2515 54 * @event wpcf7mailsent 55 * @param {Event} event 56 * @returns {void} 57 */ 58 sendContactsForm(event) { 59 dataLayer.push({ 60 event: "autoEvent", 61 eventName: "form_contact_submit", 62 }); 63 64 // Send analytics data to api (SDD-2515) 65 var $form = $("#popupResult"); 66 67 var request = { 68 user_id: "", 69 user_type: "guest", 70 event_type: "contacts", 71 event_data: this.formDataToJSON( 72 $form, 73 [ 74 "email_field", 75 "email_field_merch", 76 "g-recaptcha-response", 77 "password", 78 "_wpcf7", 79 "_wpcf7_version", 80 "_wpcf7_locale", 81 "_wpcf7_unit_tag", 82 "_wpcf7_container_post", 83 "_wpcf7_posted_data_hash", 84 ], 85 { 86 formtype: "contacts", 87 formlanguage: "<?php echo pll_current_language('slug'); ?>", 88 } 89 ), 90 }; 91 92 $.ajax({ 93 url: this.analyticsURL, 94 type: "POST", 95 dataType: "json", 96 data: request, 97 async: true, 98 success: function (data) { 99 console.log(data); 100 }, 101 error: function (jqXHR) { 102 console.log(jqXHR.responseText); 103 }, 104 }); 105 106 /** 107 * Send form data to Mailer 108 */ 109 $.ajax({ 110 url: this.sendformsURL, 111 type: "POST", 112 dataType: "json", 113 data: request.event_data, 114 async: true, 115 beforeSend: function () { 116 $("button[type='submit']").addClass("btn-loading"); 117 $(".wpcf7-response-output").hide(); // TODO: пеÑеделаÑÑ 118 }, 119 success: function (data) { 120 if (data.waiting) { 121 formServices.startCountdown( 122 data.waiting, 123 "countdown", 124 "contactFormSubmitButton" 125 ); 126 } else { 127 $("button[type='submit']").removeClass("btn-loading"); 128 $(".wpcf7-response-output").show(333); 129 grecaptcha.reset(); 130 } 131 }, 132 error: function (jqXHR) { 133 console.log(jqXHR.responseText); 134 $("button[type='submit']").removeClass("btn-loading"); 135 $(".wpcf7-response-output").show(333); // TODO: пеÑеделаÑÑ 136 grecaptcha.reset(); 137 }, 138 }); 139 } 140 141 142 143 144 startCountdown(timeStr, elementId, buttonID) { 145 const display = document.getElementById(elementId); 146 const button = document.getElementById(buttonID); 147 const timer = document.getElementById("countdown-timer"); 148 149 if (display) { 150 display.style.display = "block"; 151 } else { 152 console.error(`ÐÐ»ÐµÐ¼ÐµÐ½Ñ Ñ id "${elementId}" не найден`); 153 return; 154 } 155 156 if (button) { 157 button.disabled = true; 158 button.style.pointerEvents = "none"; 159 button.style.opacity = "0.5"; 160 button.style.cursor = "not-allowed"; 161 button.classList.add("btn-loading"); 162 // grecaptcha.reset(); 163 } else { 164 console.error(`ÐÐ»ÐµÐ¼ÐµÐ½Ñ Ñ id "${buttonID}" не найден`); 165 return; 166 } 167 168 let [hours, minutes, seconds] = timeStr.split(":").map(Number); 169 let totalSeconds = hours * 3600 + minutes * 60 + seconds; 170 171 const interval = setInterval(() => { 172 if (totalSeconds <= 0) { 173 clearInterval(interval); 174 timer.textContent = "00:00:00"; 175 display.removeAttribute("style"); 176 button.disabled = false;
177 button.style.pointerEvents = "auto"; 178 button.style.opacity = "1"; 179 button.style.cursor = "pointer"; 180 button.removeAttribute("style"); 181 button.removeAttribute("disabled"); 182 button.classList.remove("btn-loading"); 183 // grecaptcha.reset(); 184 return; 185 } 186 187 totalSeconds--; 188 const h = String(Math.floor(totalSeconds / 3600)).padStart(2, "0"); 189 const m = String(Math.floor((totalSeconds % 3600) / 60)).padStart(2, "0"); 190 const s = String(totalSeconds % 60).padStart(2, "0"); 191 timer.textContent = `${h}:${m}:${s}`; 192 }, 1000); 193 } 194 195 196 197 198 enableButton(button) { 199 button.disabled = false; 200 button.classList.remove("btn-loading"); 201 button.removeAttribute("style"); 202 button.removeAttribute("disabled"); 203 // grecaptcha.reset(); 204 } 205 206 207 208 209 disableButton(button) { 210 button.disabled = true; 211 button.classList.add("btn-loading"); 212 Object.assign(button.style, { 213 pointerEvents: "none", 214 opacity: "0.5", 215 cursor: "not-allowed", 216 }); 217 // grecaptcha.reset(); 218 } 219 220 221 222 223 /** 224 * Add formd data to json and add/remove fields 225 * @param {*} $form 226 * @param {*} removeFields 227 * @param {*} extraFields 228 * @returns 229 */ 230 formDataToJSON($form, removeFields = [], extraFields = {}) { 231 let unindexedArray = $form.serializeArray(); 232 let indexedObject = {}; 233 $.map(unindexedArray, function (field) { 234 indexedObject[field.name] = field.value; 235 }); 236 removeFields.forEach((field) => { 237 if (indexedObject.hasOwnProperty(field)) { 238 delete indexedObject[field]; 239 } 240 }); 241 Object.assign(indexedObject, extraFields); 242 return indexedObject; 243 } 244 245 246 247 248 addHttpsToInput(id) { 249 if (document.getElementById(id)) { 250 let site = document.getElementById(id); 251 site.addEventListener("change", addHttps); 252 site.addEventListener("paste", addHttps); 253 254 function addHttps() { 255 let url = this.value; 256 let pattern = 257 /http:|http:\/\/|^\W+|\<+|\>+|\,+|\ +|\.{2,}|\/{1,}|https:\/\/{1,}|https:\/{1,}|https:{1,}|:{1,}/g; 258 let result = url.replace(pattern, ""); 259 let https = result.match(/https:\/\//); 260 if (https == null) { 261 result = "https://" + result; 262 } 263 document.getElementById(id).value = result; 264 } 265 } else { 266 return false; 267 } 268 } 269 270 271 272 273 localizeErrors(lang) { 274 $.ajaxSetup({ cache: true }); 275 $.getScript( 276 "../../wp-content/themes/salesdoubler/js/languages/messages_" + 277 lang + 278 ".js" 279 ); 280 } 281 282 283 284 285 showSuccessMessage() { 286 $("button[type='submit']").removeClass("btn-loading"); 287 $("#overlay").fadeIn(); 288 $("#loader").fadeOut(); 289 $("#overlay, #closeOverlay").on("click", function () { 290 console.log("click"); 291 $("#overlay").fadeOut(); 292 }); 293 setTimeout(function () { 294 $("#overlay").fadeOut(); 295 }, 10000); 296 } 297}
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.