HEX
Server: Apache
System: Linux main79 6.1.0-52-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.180-1 (2026-08-03) x86_64
User: serwer143450 (7544)
PHP: 7.4.33
Disabled: opcache_reset, opcache_invalidate, opcache_compile_file, opcache_get_configuration, opcache_get_status
Upload Files
File: /home/platne/serwer143450/public_html/energix2/wp-content/plugins/code-snippets/js/edit/validate.ts
export const handleFormSubmitValidation = () => {
	const form = document.getElementById('snippet-form')
	const editor = window.code_snippets_editor?.codemirror
	const strings = window.code_snippets_edit_i18n
	const snippetName = document.querySelector('input[name=snippet_name]') as HTMLInputElement

	if (!form || !editor || !snippetName) {
		return
	}

	form.addEventListener('submit', (event: SubmitEvent) => {
		const missing_title = '' === snippetName.value.trim()
		const missing_code = '' === editor.getValue().trim()

		const message = missing_title ?
			missing_code ? strings.missing_title_code : strings.missing_title :
			missing_code ? strings.missing_code : ''

		if (event?.submitter?.id.startsWith('save_snippet') && message && !confirm(message)) {
			event.preventDefault()
		}
	})
}