PageSourceSearch

https://www.booksprintedizioni.it/javas/v2/controlliInput.js

js booksprintedizioni.it collected 2026-10-02 04:53:59 UTC 9,588 bytes, 280 lines download raw bytes

1/* Helper functions for the blocking layer/loader */
2function showLoader() {
3	var lockLayer = document.getElementById('blocking-layer');
4	if (!lockLayer) {
5		lockLayer = document.createElement('div');
6		lockLayer.id = 'blocking-layer';
7		// Layer visibile grigio chiaro sfocato con spinner al centro
8		lockLayer.style.cssText = 'position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(240,240,240,0.7); backdrop-filter:blur(5px); z-index:999999; cursor:wait; display:none; justify-content:center; align-items:center; transition: opacity 0.3s ease;';
9
10		var spinner = document.createElement('div');
11		spinner.style.cssText = 'width:50px; height:50px; border:6px solid #e0e0e0; border-top:6px solid #007bff; border-radius:50%; animation: spin-layer 1s linear infinite;';
12		lockLayer.appendChild(spinner);
13
14		var style = document.createElement('style');
15		style.textContent = '@keyframes spin-layer { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }';
16		document.head.appendChild(style);
17
18		document.body.appendChild(lockLayer);
19	}
20	lockLayer.style.display = 'flex';
21}
22
23function hideLoader() {
24	var lockLayer = document.getElementById('blocking-layer');
25	if (lockLayer) {
26		lockLayer.style.display = 'none';
27	}
28}
29
30/*controllo campi obbligatori*/
31function campiObbligatori(nome) {
32	nomeForm = document.forms[nome];
33	result = true;
34	for (i = 0; i < nomeForm.length; i++) {
35		if (!result) {
36			break;
37		}
38		var campo = nomeForm.elements[i]
39		altValue = campo.getAttribute("alt")
40		if (altValue == "obbligatorio") {
41			if (campo.type == 'checkbox' || campo.type == 'radio') {
42				if (!campo.checked) {
43					if (campo.name == "accetto") {
44						showModal("Attenzione", 'Attenzione: per proseguire devi spuntare la casella dove accetti la privacy e il trattamento dei dati personali.');
45						result = false
46						break;
47					}
48					if (campo.name == "confermo") {
49						showModal("Attenzione", 'Attenzione: per proseguire devi spuntare la casella dove accetti la sottoscrizione dell\'Accordo di non Divulgazione.');
50						result = false
51						break;
52					}
53					if (campo.name == "condeco") {
54						showModal("Attenzione", 'Attenzione: per proseguire devi spuntare la casella dove confermi di accettare le nostre Condizioni Economiche riservate alle Librerie.');
55						result = false
56						break;
57					}
58					else {
59						showModal("Attenzione", 'I campi contrassegnati dall\'asterisco, sono obbligatori');
60						result = false
61						break;
62					}
63				}
64			}
65			else {
66				if (campo.value == '') {
67					showModal("Attenzione", 'I campi contrassegnati dall\'asterisco, sono obbligatori');
68					result = false
69					break;
70				} else if (campo.name == "email" || campo.name == "emailREQUIRED") {
71					var iscrizione = campo.getAttribute('data-iscrizione') || '';
72					showLoader();
73
74					var xhr = new XMLHttpRequest();
75					xhr.open("GET", "/vbs/checkEmail.asp?email=" + encodeURIComponent(campo.value) + "&iscrizione=" + encodeURIComponent(iscrizione), false);
76
77					try {
78						xhr.send();
79
80						if (xhr.status === 200) {
81							var res = JSON.parse(xhr.responseText);
82							if (res.error > 0) {
83								showModal("Attenzione", res.msg);
84								result = false;
85							}
86						}
87					} finally {
88						hideLoader();
89					}
90				} else if (campo.name == "_cell") {
91					number = campo.value;
92					if (number.length > 0) {
93						cleaned = number.replace(/[\s\-()]/g, '');
94						local = cleaned.replace(/^(\+39|0039)/, '');
95						if (/^3\d{9}$/.test(local)) {
96							campo.value = local;
97						} else {
98							showModal("Attenzione", "Il numero di cellulare deve iniziare con 3 e avere 10 cifre.");
99							result = false;
100							break;
101						}
102					}
103				}
104			}
105		} else {
106			if (campo.name == "email") {
107				if (campo.value != '') {
108					var iscrizione = campo.getAttribute('data-iscrizione') || '';
109					showLoader();
110
111					var xhr = new XMLHttpRequest();
112					xhr.open("GET", "/vbs/checkEmail.asp?email=" + encodeURIComponent(campo.value) + "&iscrizione=" + encodeURIComponent(iscrizione), false);
113
114					try {
115						xhr.send();
116
117						if (xhr.status === 200) {
118							var res = JSON.parse(xhr.responseText);
119							if (res.error > 0) {
120								showModal("Attenzione", res.msg);
121								result = false;
122							}
123						}
124					} finally {
125						hideLoader();
126					}
127				}
128			} else if (campo.name == "_cell") {
129				number = campo.value;
130				if (number.length > 0) {
131					cleaned = number.replace(/[\s\-()]/g, '');
132					local = cleaned.replace(/^(\+39|0039)/, '');
133					if (/^3\d{9}$/.test(local)) {
134						campo.value = local;
135					} else {
136						showModal("Attenzione", "Il numero di cellulare deve iniziare con 3 e avere 10 cifre.");
137						result = false;
138						break;
139					}
140				}
141			}
142		}
143	}
144	return result;
145}
146
147function controlloSoloNum(evt) {
148	evt = evt || window.event;
149	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
150		((evt.which) ? evt.which : 0));
151	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
152		showModal("Attenzione", "Puoi inserire solo numeri!");
153		return false;
154	}
155	return true;
156}
157function controlloNum(evt) {
158	evt = evt || window.event;
159	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
160		((evt.which) ? evt.which : 0));
161	if (charCode > 31 && (charCode < 44 || charCode > 57)) {
162		showModal("Attenzione", "Puoi inserire solo numeri!");
163		return false;
164	}
165	return true;
166}
167
168function selezionaTutto(nome) {
169	formCont = document.forms[nome];
170	if (document.getElementById('selTutto').checked == true) {
171		for (i = 0; i < formCont.elements.length; i++) {
172			if ((formCont.elements[i].type == 'checkbox')) {
173				formCont.elements[i].checked = true
174			}
175		}
176	} else {
177		for (i = 0; i < formCont.elements.length; i++) {
178			if (formCont.elements[i].type == 'checkbox') {
179				formCont.elements[i].checked = false
180			}
181		}
182	}
183}
184
185function check(field) {
186	if (checkflag == "false") {
187		for (i = 0; i < field.length; i++) {
188			field[i].checked = true;
189		}
190		checkflag = "true";
191		return "Uncheck All";
192	} else {
193		for (i = 0; i < field.length; i++) {
194			field[i].checked = false;
195		}
196		checkflag = "false";
197		return "Check All";
198	}
199}
200
201
202
203function controllonumtel09(evt) {
204	var theEvent = evt || window.event;
205	var key = theEvent.keyCode || theEvent.which;
206	key = String.fromCharCode(key);
207	var regex = /[0-9]/;
208	if (!regex.test(key)) {
209		theEvent.returnValue = false;
210		showModal("Attenzione", "Puoi inserire solo numeri!");
211
212		if (theEvent.preventDefault) theEvent.preventDefault();
213	}
214}
215
216/* Mostra un modal personalizzato invece dell'alert */
217var currentModalCallback = null;
218function showModal(title, content, callback) {
219	currentModalCallback = callback || null;
220
221	var overlay = document.getElementById('custom-modal-overlay');
222	if (!overlay) {
223		overlay = document.createElement('div');
224		overlay.id = 'custom-modal-overlay';
225		overlay.style.cssText = 'position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(240,240,240,0.7); backdrop-filter:blur(5px); z-index:1000000; display:none; justify-content:center; align-items:center; opacity:0; transition:opacity 0.3s ease;';
226
227		var modal = document.createElement('div');
228		modal.style.cssText = 'background:#fff; padding:30px; border-radius:12px; max-width:500px; width:90%; box-shadow:0 20px 40px rgba(0,0,0,0.4); transform:scale(0.8); transition:transform 0.3s ease; font-family:"Segoe UI", Roboto, Helvetica, Arial, sans-serif;';
229
230		var titleEl = document.createElement('h2');
231		titleEl.id = 'custom-modal-title';
232		titleEl.style.cssText = 'margin-top:0; margin-bottom:15px; color:#333; font-size:24px; font-weight:600; border-bottom:1px solid #eee; padding-bottom:10px;';
233		modal.appendChild(titleEl);
234
235		var bodyEl = document.createElement('div');
236		bodyEl.id = 'custom-modal-body';
237		bodyEl.style.cssText = 'margin-bottom:25px; color:#555; line-height:1.6; font-size:16px;';
238		modal.appendChild(bodyEl);
239
240		var actions = document.createElement('div');
241		actions.style.cssText = 'display:flex; justify-content:flex-end;';
242
243		var closeBtn = document.createElement('button');
244		closeBtn.innerText = 'Chiudi';
245		closeBtn.style.cssText = 'padding:10px 24px; background:#007bff; color:#fff; border:none; border-radius:6px; cursor:pointer; font-size:16px; font-weight:500; transition:background 0.2s;';
246		closeBtn.onmouseover = function () { this.style.background = '#0056b3'; };
247		closeBtn.onmouseout = function () { this.style.background = '#007bff'; };
248		closeBtn.onclick = hideModal;
249
250		actions.appendChild(closeBtn);
251		modal.appendChild(actions);
252		overlay.appendChild(modal);
253		document.body.appendChild(overlay);
254	}
255
256	document.getElementById('custom-modal-title').innerHTML = title;
257	document.getElementById('custom-modal-body').innerHTML = content;
258
259	overlay.style.display = 'flex';
260	// Trigger reflow
261	overlay.offsetHeight;
262	overlay.style.opacity = '1';
263	overlay.firstElementChild.style.transform = 'scale(1)';
264}
265
266function hideModal() {
267	var overlay = document.getElementById('custom-modal-overlay');
268	if (overlay) {
269		overlay.style.opacity = '0';
270		overlay.firstElementChild.style.transform = 'scale(0.8)';
271		setTimeout(function () {
272			overlay.style.display = 'none';
273			if (typeof currentModalCallback === 'function') {
274				var callback = currentModalCallback;
275				currentModalCallback = null;
276				callback();
277			}
278		}, 300);
279	}
280}

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.