403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/ilovecveti.ru/bitrix/js/sale/payment-pay/lib/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/js/sale/payment-pay/lib/src/virtual-form.js
export class VirtualForm
{
	/**
	 * @private
	 * @param {HTMLFormElement|null} form
	 */
	constructor(form) {
		this.form = form || null;
	}

	/**
	 * @public
	 * @param {string} html
	 * @returns {VirtualForm}
	 */
	static createFromHtml(html) {
		const tempNode = document.createElement('div');
		tempNode.innerHTML = html;

		const form = tempNode.querySelector('form');
		return new VirtualForm(form);
	}

	/**
	 * @public
	 * @param {HTMLElement} node
	 * @returns {VirtualForm}
	 */
	static createFromNode(node) {
		if (node instanceof HTMLFormElement) {
			return new VirtualForm(node);
		}
		const form = node.querySelector('form');
		return new VirtualForm(form);
	}

	/**
	 * @public
	 * @returns {boolean}
	 */
	submit() {
		if (!this.canSubmit()) {
			return false;
		}

		if (this.isVirtual()) {
			const tempNode = document.createElement('div');
			tempNode.style.display = 'none';
			tempNode.append(this.form);

			document.body.appendChild(tempNode);
		}

		HTMLFormElement.prototype.submit.call(this.form);
		return true;
	}

	/**
	 * @public
	 * @returns {boolean}
	 */
	canSubmit() {
		return this.isValidFormObject() && this.containsAllowedInputTypesOnly();
	}

	/**
	 * @private
	 * @returns {boolean}
	 */
	isValidFormObject() {
		return this.form instanceof HTMLFormElement;
	}

	/**
	 * @private
	 * @returns {boolean}
	 */
	containsAllowedInputTypesOnly() {
		if (!this.form || !this.form.elements) {
			return false;
		}

		// eslint-disable-next-line no-plusplus
		for (let i = 0; i < this.form.elements.length; i++) {
			if (!VirtualForm.elementAllowed(this.form.elements[i])) {
				return false;
			}
		}

		return true;
	}

	/**
	 * @private
	 * @param element
	 * @returns {boolean}
	 */
	static elementAllowed(element) {
		const allowedTypes = VirtualForm.getAllowedInputTypes();
		if (element instanceof HTMLInputElement) {
			return allowedTypes.indexOf(element.type) !== -1;
		}
		return true;
	}

	/**
	 * @private
	 * @returns {string[]}
	 */
	static getAllowedInputTypes() {
		return ['hidden', 'submit'];
	}

	/**
	 * @public
	 * @returns {boolean}
	 */
	isVirtual() {
		if (this.form) {
			return !document.body.contains(this.form);
		}
		return true;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit