PageSourceSearch

https://www.online-latin-dictionary.com/inc/omc-form.js

js online-latin-dictionary.com collected 2026-10-02 10:21:06 UTC 8,712 bytes, 311 lines download raw bytes

1let retryTimeout = null;
2let debounceTimeout = null;
3let debounceStatus = true;
4let apiStatus = true;
5
6$(document).ready(function() {
7	if ($("#txtConfirmation").is(':checked')) {
8		debounce(load_captcha, 500);
9		setTimeout(() => {
10			$(".form-container .form-section.confirmation-section").fadeOut(1000);
11			$(".form-container .form-section.validation-section").fadeTo(2000, 1.0);
12		}, 1000);
13	}
14});
15
16$("#txtConfirmation").on("change", function(event) {
17	event.preventDefault();
18	if ($("#txtConfirmation").is(':checked')) {
19		debounce(load_captcha, 500);
20		setTimeout(() => {
21			$(".form-container .form-section.confirmation-section").fadeOut(1000);
22			$(".form-container .form-section.validation-section").fadeTo(2000, 1.0);
23		}, 1000);
24	}
25});
26
27$("#txtCode").on("input change", function(event) {
28	if ($("#txtCode").parent(".form-group").hasClass("has-error")) {
29		$("#txtCode").parent(".form-group").removeClass("has-error");
30	}
31});
32
33$("#captchaRefresh").on("click", function(event) {
34	event.preventDefault();
35	debounce(load_captcha, 500);
36});
37
38$("#frmContact").on("submit", function(event) {
39	event.preventDefault();
40	debounce(process_form, 3000);
41});
42
43function authorization() {
44	if (sessionStorage.getItem("form_token")) {
45		return "Bearer " + sessionStorage.getItem("form_token");
46	}
47	else {
48		clearTimeout(retryTimeout);
49		return new Promise((resolve, reject) => {
50			return $.ajax({
51				type: "POST",
52				url: "https://www.olivettimedia.com/api/authenticate.php",
53				cache: false,
54				contentType: false,
55				processData: false,
56				retryCount: 0,
57				retryLimit: 1,
58				timeout: 10000,
59				success: (function(data) {
60					let dt = JSON.parse(data);
61					if (dt["status"] && dt["status"] == true) {
62						sessionStorage.setItem("form_token", dt["token"]);
63						resolve("Bearer " + dt["token"]);
64					}
65					else {
66						sessionStorage.removeItem("form_token");
67						reject("Si è verificato un errore. Riprova più tardi.");
68					}
69				}),
70				error: (function (jqXHR, textStatus, errorThrown) {
71					sessionStorage.removeItem("form_token");
72					if (this.retryCount <= this.retryLimit) {
73						this.retryCount++;
74						retryTimeout = setTimeout(() => {
75							$.ajax(this);
76							clearTimeout(retryTimeout);
77						}, 1000);
78						return;
79					}
80					return false;
81				})
82			});
83		});
84	}
85}
86
87async function load_captcha() {
88	if (apiStatus == false) { return; }
89	apiStatus = false;
90
91	clearTimeout(retryTimeout);
92	$("#captchaImage").fadeTo(1, 0);
93	$("#captchaRefresh").addClass("spin");
94
95	let auth = await authorization();
96	$.ajax({
97		type: "POST",
98		url: "https://www.olivettimedia.com/api/captcha.php?d=" + generateCurrentDate(),
99		cache: false,
100		contentType: false,
101		processData: false,
102		retryCount: 0,
103		retryLimit: 1,
104		refreshToken: true,
105		timeout: 10000,
106		beforeSend: async function(xhr) {
107			xhr.setRequestHeader("Authorization", auth);
108		},
109		success: (function(data, textStatus, jqXHR) {
110			let dt = JSON.parse(data);
111			if (dt["status"] && dt["status"] == true) {
112				$("#captchaImage").attr("src", dt["image"]);
113				$("#captchaImage").attr("data-code", dt["code"]);
114				$("#captchaImage").fadeTo(1, 1.0);
115				$("#captchaRefresh").removeClass("spin");
116				$("#txtCode").val("");
117				$("#txtCode").parent(".form-group").removeClass("has-error");
118				apiStatus = true;
119				debounceStatus = true;
120			}
121			else {
122				this.error(jqXHR, "UNKNOWN", "Si è verificato un errore. Riprova più tardi.");
123			}
124		}),
125		error: (async function (jqXHR, textStatus, errorThrown) {
126			if (this.refreshToken == true) {
127				this.refreshToken = false;
128				sessionStorage.removeItem("form_token");
129				auth = await authorization();
130			}
131			if (this.retryCount <= this.retryLimit) {
132				this.retryCount++;
133				retryTimeout = setTimeout(() => {
134					$.ajax(this);
135					clearTimeout(retryTimeout);
136				}, 1000);
137				return;
138			}
139			$.toast({
140				text: ((errorThrown) ? errorThrown : "Si è verificato un errore. Riprova più tardi."),
141				heading: 'ERROR',
142				showHideTransition: 'fade',
143				allowToastClose: true,
144				hideAfter: 4000,
145				stack: 5,
146				position: 'bottom-center',
147				textAlign: 'left',
148				loader: true,
149				loaderBg: '#1e3799',
150			});
151			apiStatus = true;
152			debounceStatus = true;
153		})
154	});
155}
156
157async function process_form() {
158	if (apiStatus == false) { return; }
159	apiStatus = false;
160
161	clearTimeout(retryTimeout);
162	let formData = new FormData();
163	formData.append("name", $("#txtName").val());
164	formData.append("email", $("#txtEmail").val());
165	formData.append("subject", $("#txtSubject").val());
166	formData.append("message", $("#txtMessage").val());
167	formData.append("code", $("#txtCode").val());
168	formData.append("token", $("#captchaImage").attr("data-code"));
169	$("#btnSubmit").addClass("disabled").prop("disabled", true);
170
171	let auth = await authorization();
172	$.ajax({
173		type: "POST",
174		url: "https://www.olivettimedia.com/api/process_form.php",
175		data: formData,
176		cache: false,
177		contentType: false,
178		processData: false,
179		retryCount: 0,
180		retryLimit: 1,
181		refreshToken: true,
182		timeout: 10000,
183		beforeSend: function(xhr) {
184			xhr.setRequestHeader("Authorization", auth);
185		},
186		success: (function(data, textStatus, jqXHR) {
187			let dt = JSON.parse(data);
188			if (dt["status"] && dt["status"] == true) {
189				$.toast({
190					text: dt["msg"],
191					heading: 'INFORMATION',
192					showHideTransition: 'fade',
193					allowToastClose: true,
194					hideAfter: 10000,
195					stack: 5,
196					position: 'bottom-center',
197					textAlign: 'left',
198					loader: true,
199					loaderBg: '#1e3799',
200				});
201				apiStatus = true;
202				debounceStatus = true;
203				$("#btnSubmit").removeClass("disabled").prop("disabled", false);
204				clear_form();
205			}
206			else {
207				if (dt["error"] && dt["msg"]) {
208					this.error(jqXHR, dt["error"], dt["msg"]);
209				}
210				else {
211					this.error(jqXHR, "UNKNOWN", "Si è verificato un errore. Riprova più tardi.");
212				}
213			}
214		}),
215		error: (async function (jqXHR, textStatus, errorThrown) {
216			switch (textStatus) {
217				case "INVALID_INPUT":
218					break;
219				case "EXPIRED":
220				case "INVALID_CODE":
221					$("#txtCode").parent(".form-group").addClass("has-error");
222					break;
223				default:
224					if (this.refreshToken == true) {
225						this.refreshToken = false;
226						sessionStorage.removeItem("form_token");
227						auth = await authorization();
228					}
229					if (this.retryCount <= this.retryLimit) {
230						this.retryCount++;
231						retryTimeout = setTimeout(() => {
232							$.ajax(this);
233							clearTimeout(retryTimeout);
234						}, 1000);
235						return;
236					}
237					break;
238			}
239			$.toast({
240				text: ((errorThrown) ? errorThrown : "Si è verificato un errore. Riprova più tardi."),
241				heading: 'ERROR',
242				showHideTransition: 'fade',
243				allowToastClose: true,
244				hideAfter: 4000,
245				stack: 5,
246				position: 'bottom-center',
247				textAlign: 'left',
248				loader: true,
249				loaderBg: '#1e3799',
250			});
251			apiStatus = true;
252			debounceStatus = true;
253			$("#btnSubmit").removeClass("disabled").prop("disabled", false);
254		})
255	});
256}
257
258function clear_form() {
259	debounce(load_captcha, 500);
260	$("#txtName").val("");
261	$("#txtEmail").val("");
262	$("#txtSubject").val("");
263	$("#txtMessage").val("");
264	$("#txtCode").val("");
265	$("#btnSubmit").focus();
266}
267
268function debounce (callback, time) {
269	if (debounceStatus == false) { return; }
270	callback();
271	debounceStatus = false;
272	debounceTimeout = setTimeout(function() {
273		debounceStatus = true;
274		clearTimeout(debounceTimeout);
275	}, time);
276};
277
278function generateCurrentDate() {
279	let today = new Date();
280	let date = today.getFullYear() + "" + (today.getMonth()+1) + "" + today.getDate();
281	let time = today.getHours() + "" + today.getMinutes() + "" + today.getSeconds();
282	let dateTime = date + "" + time;
283	return dateTime;
284}
285
286function setCookie(name, value, days) {
287    let expires = "";
288    if (days) {
289        let date = new Date();
290        date.setTime(date.getTime() + (days*24*60*60*1000));
291        expires = "; expires=" + date.toUTCString();
292    }
293    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
294}
295
296function getCookie(name) {
297    let nameEQ = name + "=";
298    let ca = document.cookie.split(';');
299    for(let i = 0; i < ca.length; i++) {
300        let c = ca[i];
301        while (c.charAt(0)==' ') c = c.substring(1,c.length);
302        if (c.indexOf(nameEQ) == 0) {
303			return c.substring(nameEQ.length,c.length);
304		}
305    }
306    return null;
307}
308
309function eraseCookie(name) {   
310    document.cookie = name+"=; Max-Age=-99999999;";  
311}

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.