1const showError = (value, textError) => { 2 const inputElement = document.querySelector(`input[name="${value}"]`); 3 const errorTextElement = document.querySelector(`.text-error_${value}`); 4 inputElement.classList.add('error'); 5 errorTextElement.textContent = textError; 6 errorTextElement.style.opacity = '1'; 7}; 8 9const showModalError = () => { 10 const errorWindow = document.querySelector('.authorization_window-error'); 11 const errorMessage = errorWindow.querySelector('span'); 12 const errorButton = errorWindow.querySelector('.authorization_window-error_btn'); 13 14 errorWindow.style.display = 'flex'; 15 errorMessage.textContent = 'ÐÑи загÑÑзке пÑоизоÑла неизвеÑÑÐ½Ð°Ñ Ð¾Ñибка! ÐожалÑйÑÑа, попÑобÑйÑе позже.'; 16 17 errorButton.addEventListener('click', () => { 18 errorWindow.style.display = 'none'; 19 }); 20}; 21 22const handleRegistration = () => { 23 document.addEventListener('DOMContentLoaded', () => { 24 const regBtn = document.querySelector("#reg_btn"); 25 if (regBtn) { 26 regBtn.addEventListener("click", (e) => { 27 e.preventDefault(); 28 document.querySelectorAll('input').forEach(input => input.classList.remove("error")); 29 30 const regNonce = document.querySelector('#vb_new_user_nonce').value; 31 const firstName = document.querySelector('input[name="first_name"]').value; 32 const mail = document.querySelector('input[name="mail"]').value; 33 const pass = document.querySelector('input[name="pass"]').value; 34 const passConf = document.querySelector('input[name="pass_conf"]').value; 35 const approvalCheck = document.querySelector('input[name="approval_check"]').value; 36 const get = new URLSearchParams(document.location.search); 37 const token = get.get("token"); 38 39 const formData = new FormData(); 40 formData.append("nonce", regNonce); 41 formData.append("first_name", firstName); 42 formData.append("mail", mail); 43 formData.append("pass", pass); 44 formData.append("pass_conf", passConf); 45 formData.append("approval_check", approvalCheck); 46 formData.append("token", token); 47 48 fetch("check", { 49 method: "POST", 50 body: formData 51 }) 52 .then(response => response.json()) 53 .then(data => { 54 if (data.status) { 55 window.location.href = 'subscription'; 56 } else { 57 for (let key in data) { 58 if (key !== 'status') { 59 showError(key, data[key]); 60 } 61 } 62 } 63 }) 64 .catch(error => { 65 location.reload(); 66 showModalError(); 67 }); 68 }); 69 } 70 }); 71}; 72 73const handleAuthentication = () => { 74 $("#auth_btn").click(function (e) { 75 e.preventDefault(); 76 const inputFields = document.querySelectorAll("input"); 77 inputFields.forEach(input => input.classList.remove("error")); 78 79 const mailInput = document.querySelector('input[name="mail"]'); 80 const passInput = document.querySelector('input[name="pass"]'); 81 const authBtn = document.querySelector('button[name="auth_btn"]'); 82 83 if (mailInput && passInput && authBtn) { 84 const mail = mailInput.value; 85 const pass = passInput.value; 86 const authBtnValue = authBtn.value; 87 88 const formData = new FormData(); 89 formData.append("mail", mail); 90 formData.append("pass", pass); 91 formData.append("auth_btn", authBtnValue); 92 93 fetch("auth-check", { 94 method: "POST", 95 body: formData 96 }) 97 .then(response => { 98 // console.log(response); // Log the entire response 99 if (!response.ok) { 100 console.error("Server returned an error:", response.statusText); 101 // Log the response text for non-JSON responses 102 return response.text().then(text => { 103 console.error("Response text:", text); 104 throw new Error("Network response was not ok"); 105 }); 106 }else{ 107 if (response.status) { 108 window.location.href = 'account'; 109 } else { 110 handleAuthenticationError(response); 111 } 112 } 113 return response.json(); 114 }) 115 .catch(error => { 116 // console.error("Fetch error:", error); 117 handleFetchError(error); 118 }); 119 } else { 120 // Handle missing elements here 121 console.error("Some elements are missing."); 122 } 123 }); 124}; 125 126const handleAuthenticationError = (data) => { 127 for (let key in data) { 128 if (key !== 'status') { 129 showError(key, data[key]); 130 } 131 } 132 // Consider additional error handling or user feedback 133}; 134 135const handleFetchError = (error) => { 136 // showModalError(); 137 location.reload(); 138}; 139 140 141// РегиÑÑÑаÑÐ¸Ñ 142handleRegistration(); 143 144// ÐвÑоÑизаÑÐ¸Ñ 145handleAuthentication(); 146 147 148 149 150 151 152 153//ÐодÑвеÑждение поÑÑÑ 154$("#activation_btn").click(function (e) { 155 e.preventDefault(); 156 let activation_btn = $('input[name="activation_btn"]').val(); 157 158 let formData = new FormData(); 159 formData.append("activation_btn", activation_btn); 160 161 //обÑÐµÐºÑ ajax Ñо Ñв-ми ,как бÑло Ñ ÑоÑмÑ. 162 $.ajax({ 163 url: "activation_check", 164 type: "POST", 165 dataType: "json", 166 processData: false, 167 contentType: false, 168 cache: false, 169 data: formData, 170 success: function (data) { 171 let btn = document.querySelector('#activation_btn'); 172 btn.setAttribute('disabled', true); 173 btn.style.opacity = "0.5"; 174 btn.style.cursor = "default"; 175 176 if (data) { 177 btn.textContent = "ÐиÑÑмо оÑпÑавлено"; 178 } else { 179 btn.textContent = "ÐÑибка! ÐиÑÑмо не оÑпÑавлено"; 180 } 181 }, 182 error: function (jqxhr, status, errorMsg) { 183 console.log(status, errorMsg); 184 }, 185 }); 186}); 187 188 189// ÐоÑÑÑановление паÑÐ¾Ð»Ñ 190$("#reset_btn").click(function (e) { 191 e.preventDefault(); 192 $("input").removeClass("error"); 193 194 let mail = $('input[name="mail"]').val(); 195 let reset_btn = $('input[name="reset_btn"]').val(); 196 197 let formData = new FormData(); 198 formData.append("mail", mail); 199 formData.append("reset_btn", reset_btn); 200 201 //обÑÐµÐºÑ ajax Ñо Ñв-ми ,как бÑло Ñ ÑоÑмÑ. 202 $.ajax({ 203 url: "send_link_reset_password", 204 type: "POST", 205 dataType: "json", 206 processData: false, 207 contentType: false, 208 cache: false, 209 data: formData, 210 success: function (data) { 211 if (data === true) { 212 document.querySelector('.reset_password_form.authorization_form').innerHTML = `
213 <span>ÐиÑÑмо бÑло оÑпÑавлено на введеннÑй email адÑеÑ. ÐожалÑйÑÑа, пÑовеÑÑÑе ÐаÑÑ Ð¿Ð¾ÑÑÑ! ÐÑли Ð²Ñ Ð½Ðµ обнаÑÑжили пиÑÑмо в ваÑем поÑÑовом ÑÑике, пожалÑйÑÑа, пÑовеÑÑÑе Ñакже Ð¿Ð°Ð¿ÐºÑ "Спам"</span> 214 `; 215 } else { 216 showError('mail', data); 217 } 218 }, 219 error: function (jqxhr, status, errorMsg) { 220 console.log(status, errorMsg); 221 }, 222 }); 223}); 224 225 226// Смена паÑÐ¾Ð»Ñ 227$("#set_pass_btn").click(function (e) { 228 e.preventDefault(); 229 $("input").removeClass("error"); 230 231 let pass_token = $('input[name="pass_token"]').val(); 232 let pass = $('input[name="pass"]').val(); 233 let pass_conf = $('input[name="pass_conf"]').val(); 234 let set_pass_btn = $('input[name="set_pass_btn"]').val(); 235 236 237 let formData = new FormData(); 238 formData.append("pass_token", pass_token); 239 formData.append("pass", pass); 240 formData.append("pass_conf", pass_conf); 241 formData.append("set_pass_btn", set_pass_btn); 242 243 //обÑÐµÐºÑ ajax Ñо Ñв-ми ,как бÑло Ñ ÑоÑмÑ. 244 $.ajax({ 245 url: "update_password", 246 type: "POST", 247 dataType: "json", 248 processData: false, 249 contentType: false, 250 cache: false, 251 data: formData, 252 success: function (data) { 253 if (data === true) { 254 document.querySelector('.authorization_form').innerHTML = ` 255 <span>ÐÑ ÑÑпеÑно Ñменили паÑолÑ</span> 256 `; 257 setTimeout(() => window.location.href = 'auth', 3000); 258 } else { 259 if (data === 'ÐовÑоÑнÑй паÑÐ¾Ð»Ñ Ð²Ð²ÐµÐ´ÐµÐ½ не веÑно') { 260 showError('pass_conf', data); 261 } else { 262 showError('pass', data); 263 } 264 } 265 }, 266 error: function (jqxhr, status, errorMsg) { 267 console.log(status, errorMsg); 268 }, 269 }); 270}); 271 272//ÐалидаÑÐ¸Ñ Ð¿Ð°ÑÐ¾Ð»Ñ 273(() => { 274 if (document.querySelector('.password-validation_progress')) { 275 class PasswordValidation { 276 constructor() { 277 this.lowercaseLetters = false; 278 this.capitalLetters = false; 279 this.numbers = false; 280 this.length = false; 281 } 282 sizeBar() { 283 if (size < 0) { 284 size = 0; 285 } else if (size > 100) { 286 size = 100; 287 } 288 if (size > 0 && size <= 25) { 289 colorProgress.style.background = '#FF1111'; 290 } else if (size > 25 && size <= 75) { 291 colorProgress.style.background = '#FFA011'; 292 } else if (size === 100) { 293 colorProgress.style.background = '#5DFF11'; 294 } 295 296 progressBars.style.width = `${size}%`; 297 } 298 changeInput(valid, value) { 299 if (valid) { 300 if (!this[value]) { 301 this[value] = true; 302 size += 25; 303 this.sizeBar(); 304 } 305 } else { 306 if (this[value]) { 307 this[value] = false; 308 size -= 25; 309 this.sizeBar(); 310 } 311 } 312 313 } 314 } 315 316 const passwordValidation = new PasswordValidation(); 317 const inputPassword = document.querySelector('.pers_item .pers_input input[name="pass"]'); 318 const progressBars = document.querySelector('.password-validation_progress'); 319 let colorProgress = document.querySelector('.password-validation_progress'); 320 let size = Number(progressBars.dataset.size); 321 322 inputPassword.addEventListener('keyup', function () { 323 // Validate lowercase letters 324 let lowerCaseLetters = /[a-z]/g; 325 if (inputPassword.value.match(lowerCaseLetters)) { 326 passwordValidation.changeInput(true, 'lowercaseLetters'); 327 } else { 328 passwordValidation.changeInput(false, 'lowercaseLetters'); 329 } 330 // Validate capital letters 331 let upperCaseLetters = /[A-Z]/g; 332 if (inputPassword.value.match(upperCaseLetters)) { 333 passwordValidation.changeInput(true, 'capitalLetters'); 334 } else { 335 passwordValidation.changeInput(false, 'capitalLetters'); 336 } 337 // Validate numbers 338 let numbers = /[0-9]/g; 339 if (inputPassword.value.match(numbers)) { 340 passwordValidation.changeInput(true, 'numbers'); 341 } else { 342 passwordValidation.changeInput(false, 'numbers'); 343 } 344 // Validate length 345 if (inputPassword.value.length >= 8) { 346 passwordValidation.changeInput(true, 'length'); 347 } else { 348 passwordValidation.changeInput(false, 'length'); 349 } 350 }) 351 } 352})();
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.