1/** 2 * ÐлаÑÑ ÑпÑÐ°Ð²Ð»ÐµÐ½Ð¸Ñ Ð²ÐµÐ±-ÑоÑмой 3 * 4 */ 5class PersonalOfferForm { 6 constructor(id, options) { 7 this.form = document.getElementById(id); 8 this.submitBtn = this.form.querySelector('[type="submit"]') 9 this.error = document.querySelector('[data-error-block] > [data-message]'); 10 this.success = document.querySelector('[data-success-block]'); 11 this.signedParameters = options.signedParameters; 12 13 if (this.form) { 14 this.form.addEventListener('submit', this.onSubmit.bind(this)); 15 } 16 } 17 18 async onSubmit(e) { 19 e.preventDefault(); 20 this.setError(''); 21 this.submitBtn.disabled = true 22 this.hideSuccess(); 23 try { 24 const { data } = await BX.ajax.runComponentAction('wl:form', 'save', { 25 signedParameters: this.signedParameters, 26 data: new FormData(e.currentTarget) 27 }); 28 this.showSuccess(); 29 this.form.reset(); 30 } catch (e) { 31 this.setError(e.errors); 32 } finally { 33 this.submitBtn.disabled = false 34 } 35 } 36 37 hideSuccess() { 38 if (this.success) { 39 this.success.style.display = 'none'; 40 const wrapper = this.form.querySelector('[data-form-fields-wrapper]'); 41 if (wrapper) wrapper.style.display = 'block'; 42 } 43 } 44 45 showSuccess() { 46 if (this.success) { 47 const wrapper = this.form.querySelector('[data-form-fields-wrapper]'); 48 if (wrapper) wrapper.style.display = 'none'; 49 50 this.success.style.display = 'block'; 51 } 52 } 53 54 setError(error) { 55 if (error) { 56 this.error.innerHTML = error.map((item) => item.message).join('<br>'); 57 } 58 this.error.parentNode.style.display = error ? 'block' : 'none'; 59 } 60}
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.