PageSourceSearch

https://www.hoteldianajesolo.it/themes/hoteldianajesolo/js/cro.js?v=1.x

js hoteldianajesolo.it collected 2026-09-26 21:14:27 UTC 4,545 bytes, 175 lines download raw bytes

1jQuery(document).ready(function ($) {
2	const form_name = '.webform-submission-richieste-form';
3	const $form = $(form_name);
4
5	if ($form.length === 0) {
6		return;
7	}
8
9	const lang = (document.documentElement.lang || 'it')
10		.toLowerCase()
11		.substring(0, 2);
12
13	const translations = {
14		it: {
15			treatmentRequired: 'Seleziona un trattamento.',
16			nameRequired: 'Il nome è obbligatorio.',
17			emailRequired: "L'email è obbligatoria.",
18			privacyRequired: "Devi accettare l'informativa privacy.",
19			sending: 'Invio in corso...',
20			success: 'Richiesta inviata con successo.',
21			genericError: 'Si è verificato un errore, riprova.',
22			communicationError:
23				'Errore di comunicazione con il server, riprova più tardi.',
24		},
25
26		en: {
27			treatmentRequired: 'Please select a treatment.',
28			nameRequired: 'Name is required.',
29			emailRequired: 'Email is required.',
30			privacyRequired: 'You must accept the privacy policy.',
31			sending: 'Sending...',
32			success: 'Request sent successfully.',
33			genericError: 'An error occurred. Please try again.',
34			communicationError:
35				'Communication error with the server. Please try again later.',
36		},
37
38		de: {
39			treatmentRequired: 'Bitte wählen Sie eine Behandlung aus.',
40			nameRequired: 'Der Name ist erforderlich.',
41			emailRequired: 'Die E-Mail-Adresse ist erforderlich.',
42			privacyRequired: 'Sie müssen die Datenschutzerklärung akzeptieren.',
43			sending: 'Wird gesendet...',
44			success: 'Anfrage erfolgreich gesendet.',
45			genericError:
46				'Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.',
47			communicationError:
48				'Kommunikationsfehler mit dem Server. Bitte versuchen Sie es später erneut.',
49		},
50
51		fr: {
52			treatmentRequired: 'Veuillez sélectionner un traitement.',
53			nameRequired: 'Le nom est obligatoire.',
54			emailRequired: "L'adresse e-mail est obligatoire.",
55			privacyRequired: 'Vous devez accepter la politique de confidentialité.',
56			sending: 'Envoi en cours...',
57			success: 'Demande envoyée avec succès.',
58			genericError: 'Une erreur est survenue. Veuillez réessayer.',
59			communicationError:
60				'Erreur de communication avec le serveur. Veuillez réessayer plus tard.',
61		},
62	};
63
64	const t = translations[lang] || translations.it;
65
66	$form.on('submit', function (e) {
67		e.preventDefault();
68
69		const $submitBtn = $form.find('#edit-submit');
70		const $messages = getOrCreateMessageContainer($form);
71
72		const data = {};
73
74		$form.serializeArray().forEach(function (field) {
75			data[field.name] = field.value;
76		});
77
78		data.accetto_privacy = $form.find('#edit-accetto-privacy').is(':checked')
79			? 1
80			: 0;
81
82		data.newsletter = $form.find('#edit-newsletter').is(':checked') ? 1 : 0;
83
84		const errors = validate(data);
85
86		if (errors.length > 0) {
87			showMessage($messages, errors.join(' '), 'error');
88			return;
89		}
90
91		$submitBtn.prop('disabled', true).addClass('is-disabled');
92
93		showMessage($messages, t.sending, 'info');
94
95		$.ajax({
96			url: '/cro-zucchetti/request.php',
97			method: 'POST',
98			dataType: 'json',
99			contentType: 'application/json',
100			data: JSON.stringify(data),
101		})
102			.done(function (response) {
103				if (response && response.status) {
104					showMessage($messages, response.message || t.success, 'success');
105
106					$form[0].reset();
107				} else {
108					showMessage(
109						$messages,
110						(response && response.message) || t.genericError,
111						'error',
112					);
113				}
114			})
115			.fail(function (xhr) {
116				const msg =
117					(xhr.responseJSON && xhr.responseJSON.message) ||
118					t.communicationError;
119
120				showMessage($messages, msg, 'error');
121			})
122			.always(function () {
123				$submitBtn.prop('disabled', false).removeClass('is-disabled');
124			});
125	});
126
127	function validate(data) {
128		const errors = [];
129
130		if (!data.trattamento) {
131			errors.push(t.treatmentRequired);
132		}
133
134		if (!data.nome) {
135			errors.push(t.nameRequired);
136		}
137
138		if (!data.email) {
139			errors.push(t.emailRequired);
140		}
141
142		if (!data.accetto_privacy) {
143			errors.push(t.privacyRequired);
144		}
145
146		return errors;
147	}
148
149	function getOrCreateMessageContainer($form) {
150		let $msg = $form.find('.ajax-form-messages');
151
152		if ($msg.length === 0) {
153			$msg = $('<div class="ajax-form-messages" role="alert"></div>');
154
155			$form.prepend($msg);
156		}
157
158		return $msg;
159	}
160
161	function showMessage($container, text, type) {
162		const cls =
163			type === 'error'
164				? 'messages--error'
165				: type === 'success'
166					? 'messages--status'
167					: 'messages--info';
168
169		$container
170			.removeClass('messages--error messages--status messages--info')
171			.addClass('messages ' + cls)
172			.text(text)
173			.show();
174	}
175});

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.