1459 lines
41 KiB
JavaScript
1459 lines
41 KiB
JavaScript
// JavaScript Document
|
|
|
|
|
|
/***************************************************/
|
|
/***************************************************/
|
|
/* PAGINA INDEX.JSP */
|
|
/***************************************************/
|
|
/***************************************************/
|
|
function searchFS() {
|
|
|
|
var f = document.frmFS;
|
|
|
|
Ab.submitAj('frmFS', 'gareFS');
|
|
console.log("1 fatto..");
|
|
|
|
|
|
}
|
|
|
|
function searchFE() {
|
|
|
|
f
|
|
Ab.submitAj('frmFE', 'gareFE');
|
|
console.log("2 fatto..");
|
|
|
|
}
|
|
|
|
function prevPageFS() {
|
|
var f = document.frmFS;
|
|
//
|
|
var currentPage=eval($("#pageNumberFS").val());
|
|
//alert(currentPage );
|
|
if(currentPage>1)
|
|
{
|
|
f.pageNumberFS.value =currentPage - 1;
|
|
Ab.submitAj('frmFS', 'gareFS');
|
|
}
|
|
|
|
}
|
|
|
|
function nextPageFS() {
|
|
var f = document.frmFS;
|
|
//
|
|
var currentPage=eval($("#pageNumberFS").val());
|
|
var totPage=eval($("#totPageNumber_0").val());
|
|
//alert(currentPage +" "+totPage );
|
|
if(currentPage<totPage)
|
|
{
|
|
f.pageNumberFS.value = currentPage + 1;
|
|
//alert(f.pageNumberFS.value);
|
|
Ab.submitAj('frmFS', 'gareFS');
|
|
}
|
|
|
|
}
|
|
|
|
function prevPageFE() {
|
|
var f = document.frmFE;
|
|
//
|
|
var currentPage=eval($("#pageNumberFE").val());
|
|
//alert(currentPage );
|
|
if(currentPage>1)
|
|
{
|
|
f.pageNumberFE.value =currentPage - 1;
|
|
Ab.submitAj('frmFE', 'gareFE');
|
|
}
|
|
}
|
|
|
|
function nextPageFE() {
|
|
var f = document.frmFE;
|
|
//
|
|
var currentPage=eval($("#pageNumberFE").val());
|
|
var totPage=eval($("#totPageNumber_1").val());
|
|
//alert(currentPage +" "+totPage );
|
|
if(currentPage<totPage)
|
|
{
|
|
f.pageNumberFE.value = currentPage + 1;
|
|
//alert(f.pageNumberFS.value);
|
|
Ab.submitAj('frmFE', 'gareFE');
|
|
}
|
|
}
|
|
/***************************************************/
|
|
/***************************************************/
|
|
/* PAGINA GARA.CR */
|
|
/***************************************************/
|
|
/***************************************************/
|
|
function searchGara() {
|
|
//eventi,Gara.abl,search,,@id_tipoGara@flgMese@anno@pageNumber
|
|
var f = document.main;
|
|
$("body").addClass("loading");
|
|
f.submit();
|
|
//Ab.submitAj('main');
|
|
|
|
|
|
}
|
|
/***************************************************/
|
|
/***************************************************/
|
|
/* PAGINA RICERCA FOTOCR */
|
|
/***************************************************/
|
|
/***************************************************/
|
|
function getTipoPuntoFotoValue() {
|
|
var field = $("#tipoPuntoFoto");
|
|
if (!field.length) {
|
|
return "";
|
|
}
|
|
|
|
return field.val() || "";
|
|
}
|
|
|
|
function getCurrentLangValue() {
|
|
var field = $("#lang");
|
|
if (field.length && field.val()) {
|
|
return field.val();
|
|
}
|
|
|
|
return $("html").attr("lang") || "it";
|
|
}
|
|
|
|
function getFaceAiStorageValue(fieldId, simulatorKey) {
|
|
var field = $("#" + fieldId);
|
|
if (field.length && field.val()) {
|
|
return field.val();
|
|
}
|
|
|
|
if (window.faceAiSimulator && window.faceAiSimulator.raceStorage && window.faceAiSimulator.raceStorage[simulatorKey]) {
|
|
return window.faceAiSimulator.raceStorage[simulatorKey];
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
function faceAiFeatureEnabled() {
|
|
var config = window.faceAiConfig || {};
|
|
var simulatorConfig = window.faceAiSimulator || {};
|
|
var value = typeof config.enabled !== "undefined" ? config.enabled : simulatorConfig.enabled;
|
|
|
|
if (typeof value === "string") {
|
|
value = value.toLowerCase();
|
|
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
}
|
|
|
|
return value === true;
|
|
}
|
|
|
|
function faceAiEscapeHtml(value) {
|
|
return String(value || "")
|
|
.replace(/&/g, "&")
|
|
.replace(/</g, "<")
|
|
.replace(/>/g, ">")
|
|
.replace(/"/g, """)
|
|
.replace(/'/g, "'");
|
|
}
|
|
|
|
function isFaceAiDebugEnabled() {
|
|
var hostname = window.location && window.location.hostname ? window.location.hostname : "";
|
|
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
}
|
|
|
|
function getFaceAiDebugPayload() {
|
|
var raceYear = getFaceAiStorageValue("faceAiRaceYear", "year");
|
|
var raceMonthFolder = getFaceAiStorageValue("faceAiRaceMonthFolder", "monthFolder");
|
|
var raceFolder = getFaceAiStorageValue("faceAiRaceFolder", "raceFolder");
|
|
var racePathBase = $("#faceAiRacePathBase").val() || "";
|
|
var raceStorageRelativeDir = $("#faceAiRaceStorageRelativeDir").val() || [raceYear, raceMonthFolder, raceFolder].filter(Boolean).join("/");
|
|
var simulatorConfig = window.faceAiSimulator || null;
|
|
|
|
return {
|
|
pageUrl: window.location.href,
|
|
race: {
|
|
id: $("#id_gara").val() || "",
|
|
slug: $("#garaDesc").val() || "",
|
|
name: $("h1.my-4").last().text().replace(/\s+/g, " ").trim(),
|
|
lang: getCurrentLangValue(),
|
|
storage: {
|
|
year: raceYear,
|
|
monthFolder: raceMonthFolder,
|
|
raceFolder: raceFolder,
|
|
pathBase: racePathBase,
|
|
relativeDir: raceStorageRelativeDir
|
|
}
|
|
},
|
|
simulator: simulatorConfig,
|
|
handoff: {
|
|
url: (simulatorConfig && simulatorConfig.handoffUrl) || "faceai_handoff.php",
|
|
returnUrl: (simulatorConfig && simulatorConfig.returnUrl) || window.location.href
|
|
}
|
|
};
|
|
}
|
|
|
|
function logFaceAiDebug(label, extraPayload) {
|
|
if (!isFaceAiDebugEnabled() || !window.console || typeof window.console.groupCollapsed !== "function") {
|
|
return;
|
|
}
|
|
|
|
var payload = getFaceAiDebugPayload();
|
|
if (extraPayload) {
|
|
payload.extra = extraPayload;
|
|
}
|
|
|
|
window.console.groupCollapsed("[FaceAI] " + label);
|
|
window.console.log(payload);
|
|
window.console.groupEnd();
|
|
}
|
|
|
|
function getFaceAiErrorState() {
|
|
if (typeof URLSearchParams === "undefined") {
|
|
return null;
|
|
}
|
|
|
|
var params = new URLSearchParams(window.location.search || "");
|
|
if (params.get("faceaiError") !== "1") {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
title: params.get("faceaiErrorTitle") || "Face ID non disponibile",
|
|
message: params.get("faceaiErrorMessage") || "Il servizio Face ID non e al momento disponibile. Riprova piu tardi."
|
|
};
|
|
}
|
|
|
|
function clearFaceAiErrorState() {
|
|
if (!window.history || !window.history.replaceState || typeof URL === "undefined") {
|
|
return;
|
|
}
|
|
|
|
var cleanUrl = new URL(window.location.href);
|
|
cleanUrl.searchParams.delete("faceaiError");
|
|
cleanUrl.searchParams.delete("faceaiErrorTitle");
|
|
cleanUrl.searchParams.delete("faceaiErrorMessage");
|
|
window.history.replaceState({}, document.title, cleanUrl.pathname + cleanUrl.search + cleanUrl.hash);
|
|
}
|
|
|
|
function getFaceAiMatchStorageEntryKey(storageKey) {
|
|
return "faceai-match-state:" + String(storageKey || "").trim();
|
|
}
|
|
|
|
function getFaceAiPendingMatchEntryKey() {
|
|
return "faceai-pending-match-state";
|
|
}
|
|
|
|
function getFaceAiPathForComparison(value) {
|
|
if (!value) {
|
|
return "";
|
|
}
|
|
|
|
try {
|
|
return decodeURIComponent(String(value));
|
|
} catch (error) {
|
|
return String(value);
|
|
}
|
|
}
|
|
|
|
function getFaceAiCurrentRaceId() {
|
|
return String($("#id_gara").val() || "").trim();
|
|
}
|
|
|
|
function isFaceAiStoredPayloadFresh(storedAt, maxAgeMs) {
|
|
var timestamp = Date.parse(String(storedAt || ""));
|
|
|
|
if (!timestamp) {
|
|
return false;
|
|
}
|
|
|
|
return (Date.now() - timestamp) <= maxAgeMs;
|
|
}
|
|
|
|
function canUseFaceAiWebStorage(storage) {
|
|
var testKey = "__faceai_storage_test__";
|
|
|
|
if (!storage) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
storage.setItem(testKey, "1");
|
|
storage.removeItem(testKey);
|
|
return true;
|
|
} catch (error) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function readFaceAiStoredMatchPayload(storageKey) {
|
|
var entryKey = getFaceAiMatchStorageEntryKey(storageKey);
|
|
var rawPayload = "";
|
|
var windowNamePayload;
|
|
|
|
if (!storageKey) {
|
|
return null;
|
|
}
|
|
|
|
if (canUseFaceAiWebStorage(window.sessionStorage)) {
|
|
rawPayload = window.sessionStorage.getItem(entryKey) || "";
|
|
}
|
|
|
|
if (!rawPayload && canUseFaceAiWebStorage(window.localStorage)) {
|
|
rawPayload = window.localStorage.getItem(entryKey) || "";
|
|
}
|
|
|
|
if (!rawPayload && window.name) {
|
|
try {
|
|
windowNamePayload = JSON.parse(window.name);
|
|
if (windowNamePayload && windowNamePayload.faceAiStorageKey === storageKey && windowNamePayload.faceAiMatchState) {
|
|
rawPayload = JSON.stringify(windowNamePayload.faceAiMatchState);
|
|
}
|
|
} catch (error) {
|
|
rawPayload = "";
|
|
}
|
|
}
|
|
|
|
if (!rawPayload) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
return JSON.parse(rawPayload);
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function readFaceAiPendingMatchPayload() {
|
|
var entryKey = getFaceAiPendingMatchEntryKey();
|
|
var rawPayload = "";
|
|
var parsedPayload = null;
|
|
var windowNamePayload;
|
|
var currentPath = getFaceAiPathForComparison(window.location.pathname || "");
|
|
var currentRaceId = getFaceAiCurrentRaceId();
|
|
|
|
if (canUseFaceAiWebStorage(window.sessionStorage)) {
|
|
rawPayload = window.sessionStorage.getItem(entryKey) || "";
|
|
}
|
|
|
|
if (!rawPayload && canUseFaceAiWebStorage(window.localStorage)) {
|
|
rawPayload = window.localStorage.getItem(entryKey) || "";
|
|
}
|
|
|
|
if (!rawPayload && window.name) {
|
|
try {
|
|
windowNamePayload = JSON.parse(window.name);
|
|
if (windowNamePayload && windowNamePayload.faceAiPendingMatchState) {
|
|
rawPayload = JSON.stringify(windowNamePayload.faceAiPendingMatchState);
|
|
}
|
|
} catch (error) {
|
|
rawPayload = "";
|
|
}
|
|
}
|
|
|
|
if (!rawPayload) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
parsedPayload = JSON.parse(rawPayload);
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
|
|
if (!parsedPayload || !parsedPayload.payload || !parsedPayload.payload.photoIds || !parsedPayload.payload.photoIds.length) {
|
|
return null;
|
|
}
|
|
|
|
if (!isFaceAiStoredPayloadFresh(parsedPayload.payload.storedAt, 15 * 60 * 1000)) {
|
|
return null;
|
|
}
|
|
|
|
if (String(parsedPayload.raceId || "").trim() && currentRaceId && String(parsedPayload.raceId || "").trim() !== currentRaceId) {
|
|
return null;
|
|
}
|
|
|
|
if (!String(parsedPayload.raceId || "").trim() && getFaceAiPathForComparison(parsedPayload.targetPath || "") !== currentPath) {
|
|
return null;
|
|
}
|
|
|
|
return parsedPayload;
|
|
}
|
|
|
|
function clearFaceAiStoredMatchPayload(storageKey) {
|
|
var entryKey = getFaceAiMatchStorageEntryKey(storageKey);
|
|
var pendingEntryKey = getFaceAiPendingMatchEntryKey();
|
|
var windowNamePayload;
|
|
var pendingPayload = readFaceAiPendingMatchPayload();
|
|
|
|
if (!storageKey) {
|
|
return;
|
|
}
|
|
|
|
if (canUseFaceAiWebStorage(window.sessionStorage)) {
|
|
window.sessionStorage.removeItem(entryKey);
|
|
}
|
|
|
|
if (canUseFaceAiWebStorage(window.localStorage)) {
|
|
window.localStorage.removeItem(entryKey);
|
|
if (pendingPayload && pendingPayload.storageKey === storageKey) {
|
|
window.localStorage.removeItem(pendingEntryKey);
|
|
}
|
|
}
|
|
|
|
if (canUseFaceAiWebStorage(window.sessionStorage) && pendingPayload && pendingPayload.storageKey === storageKey) {
|
|
window.sessionStorage.removeItem(pendingEntryKey);
|
|
}
|
|
|
|
if (!window.name) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
windowNamePayload = JSON.parse(window.name);
|
|
if (windowNamePayload && windowNamePayload.faceAiStorageKey === storageKey) {
|
|
delete windowNamePayload.faceAiStorageKey;
|
|
delete windowNamePayload.faceAiMatchState;
|
|
}
|
|
if (windowNamePayload && windowNamePayload.faceAiPendingMatchState && windowNamePayload.faceAiPendingMatchState.storageKey === storageKey) {
|
|
delete windowNamePayload.faceAiPendingMatchState;
|
|
}
|
|
if (!windowNamePayload || !Object.keys(windowNamePayload).length) {
|
|
window.name = "";
|
|
} else {
|
|
window.name = JSON.stringify(windowNamePayload);
|
|
}
|
|
} catch (error) {}
|
|
}
|
|
|
|
function showFaceAiErrorModal(title, message) {
|
|
var modal = $("#faceAiErrorModal");
|
|
|
|
if (!modal.length) {
|
|
$("body").append('<div class="modal fade" id="faceAiErrorModal" tabindex="-1" role="dialog" aria-labelledby="faceAiErrorModalLabel" aria-hidden="true"><div class="modal-dialog modal-sm" role="document"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="faceAiErrorModalLabel"></h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fa fa-close"></i> </button></div><div class="modal-body text-center"><p id="faceAiErrorModalMessage" class="mb-0"></p></div></div></div></div>');
|
|
modal = $("#faceAiErrorModal");
|
|
}
|
|
|
|
$("#faceAiErrorModalLabel").html(faceAiEscapeHtml(title));
|
|
$("#faceAiErrorModalMessage").html(faceAiEscapeHtml(message));
|
|
modal.modal("show");
|
|
}
|
|
|
|
function initFaceAiErrorModal() {
|
|
var errorState = getFaceAiErrorState();
|
|
if (!errorState) {
|
|
return;
|
|
}
|
|
|
|
showFaceAiErrorModal(errorState.title, errorState.message);
|
|
clearFaceAiErrorState();
|
|
}
|
|
|
|
function stripFaceAiStateFromUrl(url) {
|
|
var fallbackUrl = window.location.href;
|
|
|
|
if (typeof URL === "undefined") {
|
|
return url || fallbackUrl;
|
|
}
|
|
|
|
try {
|
|
var cleanUrl = new URL(url || fallbackUrl, window.location.href);
|
|
cleanUrl.searchParams.delete("faceaiError");
|
|
cleanUrl.searchParams.delete("faceaiErrorTitle");
|
|
cleanUrl.searchParams.delete("faceaiErrorMessage");
|
|
cleanUrl.searchParams.delete("faceaiMatchSource");
|
|
cleanUrl.searchParams.delete("faceaiMatchCount");
|
|
cleanUrl.searchParams.delete("faceaiPhotoIds");
|
|
cleanUrl.searchParams.delete("faceaiMatchStorageKey");
|
|
cleanUrl.searchParams.delete("faceaiResultId");
|
|
cleanUrl.searchParams.delete("faceaiToken");
|
|
return cleanUrl.toString();
|
|
} catch (error) {
|
|
return url || fallbackUrl;
|
|
}
|
|
}
|
|
|
|
function buildFaceAiBackendBaseUrl() {
|
|
var configuredUrl = "";
|
|
var parsedUrl;
|
|
|
|
if (window.faceAiConfig && window.faceAiConfig.backendBaseUrl) {
|
|
configuredUrl = String(window.faceAiConfig.backendBaseUrl || "").trim();
|
|
}
|
|
|
|
if (!configuredUrl && window.faceAiSimulator && window.faceAiSimulator.handoffUrl) {
|
|
configuredUrl = String(window.faceAiSimulator.handoffUrl || "").trim();
|
|
}
|
|
|
|
if (!configuredUrl) {
|
|
return "";
|
|
}
|
|
|
|
try {
|
|
parsedUrl = new URL(configuredUrl, window.location.href);
|
|
return parsedUrl.origin;
|
|
} catch (error) {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function getFaceAiDirectReturnState() {
|
|
if (typeof URLSearchParams === "undefined") {
|
|
return null;
|
|
}
|
|
|
|
var params = new URLSearchParams(window.location.search || "");
|
|
var resultId = String(params.get("faceaiResultId") || "").trim();
|
|
var token = String(params.get("faceaiToken") || "").trim();
|
|
var backendBaseUrl = buildFaceAiBackendBaseUrl();
|
|
|
|
if (!resultId || !token || !backendBaseUrl) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
resultId: resultId,
|
|
token: token,
|
|
backendBaseUrl: backendBaseUrl,
|
|
clearUrl: stripFaceAiStateFromUrl(window.location.href)
|
|
};
|
|
}
|
|
|
|
function persistFaceAiDirectReturnPayload(matchState, clearUrl) {
|
|
var storageKey;
|
|
var entryKey;
|
|
var pendingEntryKey;
|
|
var payload;
|
|
var pendingPayload;
|
|
var photoIdSet = {};
|
|
var index;
|
|
|
|
if (!matchState || !matchState.photoIds || !matchState.photoIds.length) {
|
|
return false;
|
|
}
|
|
|
|
storageKey = "faceai-result-" + String(matchState.resultId || "").replace(/[^a-zA-Z0-9_-]/g, "");
|
|
entryKey = getFaceAiMatchStorageEntryKey(storageKey);
|
|
pendingEntryKey = getFaceAiPendingMatchEntryKey();
|
|
payload = {
|
|
photoIds: matchState.photoIds.slice(0),
|
|
matchCount: matchState.matchCount,
|
|
storedAt: new Date().toISOString()
|
|
};
|
|
pendingPayload = {
|
|
storageKey: storageKey,
|
|
raceId: String(matchState.raceId || getFaceAiCurrentRaceId() || "").trim(),
|
|
targetPath: (function() {
|
|
try {
|
|
return String(new URL(clearUrl || window.location.href, window.location.href).pathname || "");
|
|
} catch (error) {
|
|
return window.location.pathname || "";
|
|
}
|
|
}()),
|
|
payload: payload
|
|
};
|
|
|
|
if (canUseFaceAiWebStorage(window.sessionStorage)) {
|
|
window.sessionStorage.setItem(entryKey, JSON.stringify(payload));
|
|
window.sessionStorage.setItem(pendingEntryKey, JSON.stringify(pendingPayload));
|
|
}
|
|
|
|
if (canUseFaceAiWebStorage(window.localStorage)) {
|
|
window.localStorage.setItem(entryKey, JSON.stringify(payload));
|
|
window.localStorage.setItem(pendingEntryKey, JSON.stringify(pendingPayload));
|
|
}
|
|
|
|
try {
|
|
window.name = JSON.stringify({
|
|
faceAiStorageKey: storageKey,
|
|
faceAiMatchState: payload,
|
|
faceAiPendingMatchState: pendingPayload
|
|
});
|
|
} catch (error) {}
|
|
|
|
for (index = 0; index < payload.photoIds.length; index += 1) {
|
|
photoIdSet[payload.photoIds[index]] = true;
|
|
}
|
|
|
|
window.faceAiMatchState = {
|
|
photoIds: payload.photoIds,
|
|
photoIdSet: photoIdSet,
|
|
matchCount: payload.matchCount,
|
|
storageKey: storageKey,
|
|
clearUrl: clearUrl || stripFaceAiStateFromUrl(window.location.href),
|
|
resultId: matchState.resultId,
|
|
raceId: pendingPayload.raceId
|
|
};
|
|
|
|
return true;
|
|
}
|
|
|
|
function hydrateFaceAiDirectReturn() {
|
|
var directReturnState = getFaceAiDirectReturnState();
|
|
|
|
if (!directReturnState) {
|
|
return $.Deferred().resolve(false).promise();
|
|
}
|
|
|
|
return $.getJSON(directReturnState.backendBaseUrl + "/bridge/results/" + encodeURIComponent(directReturnState.resultId), {
|
|
token: directReturnState.token
|
|
}).then(function(payload) {
|
|
var matches = payload && payload.matches ? payload.matches : [];
|
|
var photoIds = [];
|
|
var photoIdLookup = {};
|
|
var index;
|
|
var photoId;
|
|
|
|
for (index = 0; index < matches.length; index += 1) {
|
|
photoId = String((matches[index] && (matches[index].photoId || matches[index].id)) || "").trim();
|
|
if (!photoId || photoIdLookup[photoId]) {
|
|
continue;
|
|
}
|
|
photoIdLookup[photoId] = true;
|
|
photoIds.push(photoId);
|
|
}
|
|
|
|
persistFaceAiDirectReturnPayload({
|
|
resultId: directReturnState.resultId,
|
|
raceId: String((payload && payload.raceId) || "").trim(),
|
|
photoIds: photoIds,
|
|
matchCount: photoIds.length
|
|
}, directReturnState.clearUrl);
|
|
|
|
window.location.replace(directReturnState.clearUrl);
|
|
return true;
|
|
}, function() {
|
|
return false;
|
|
});
|
|
}
|
|
|
|
function getFaceAiMatchState() {
|
|
if (typeof URLSearchParams === "undefined") {
|
|
return null;
|
|
}
|
|
|
|
var params = new URLSearchParams(window.location.search || "");
|
|
var rawIds = params.get("faceaiPhotoIds") || "";
|
|
var storageKey = String(params.get("faceaiMatchStorageKey") || "").trim();
|
|
var storedPayload = null;
|
|
var pendingPayload = null;
|
|
|
|
if (!rawIds && storageKey) {
|
|
storedPayload = readFaceAiStoredMatchPayload(storageKey);
|
|
if (storedPayload && storedPayload.photoIds && storedPayload.photoIds.length) {
|
|
rawIds = storedPayload.photoIds.join(",");
|
|
}
|
|
}
|
|
|
|
if (!rawIds) {
|
|
pendingPayload = readFaceAiPendingMatchPayload();
|
|
if (pendingPayload && pendingPayload.payload && pendingPayload.payload.photoIds && pendingPayload.payload.photoIds.length) {
|
|
rawIds = pendingPayload.payload.photoIds.join(",");
|
|
storageKey = storageKey || String(pendingPayload.storageKey || "").trim();
|
|
storedPayload = storedPayload || pendingPayload.payload;
|
|
}
|
|
}
|
|
|
|
if (!rawIds) {
|
|
return null;
|
|
}
|
|
|
|
var photoIds = rawIds.split(",").map(function(value) {
|
|
return String(value || "").trim();
|
|
}).filter(function(value) {
|
|
return value.length > 0;
|
|
});
|
|
|
|
if (!photoIds.length) {
|
|
return null;
|
|
}
|
|
|
|
var photoIdSet = {};
|
|
for (var index = 0; index < photoIds.length; index += 1) {
|
|
photoIdSet[photoIds[index]] = true;
|
|
}
|
|
|
|
var parsedCount = parseInt(params.get("faceaiMatchCount"), 10);
|
|
|
|
return {
|
|
photoIds: photoIds,
|
|
photoIdSet: photoIdSet,
|
|
matchCount: isNaN(parsedCount) ? ((storedPayload && storedPayload.matchCount) ? storedPayload.matchCount : photoIds.length) : parsedCount,
|
|
storageKey: storageKey,
|
|
clearUrl: stripFaceAiStateFromUrl(window.location.href)
|
|
};
|
|
}
|
|
|
|
function getFaceAiFilterCopy() {
|
|
var lang = String(getCurrentLangValue() || "it").toLowerCase();
|
|
if (lang.indexOf("en") === 0) {
|
|
return {
|
|
bannerTitle: "Face ID filter active",
|
|
bannerText: "Showing <strong>{count}</strong> matched photos on the normal race page.",
|
|
clearText: "Show all race photos",
|
|
emptyText: "No matched FaceAI photos are available in this current race view."
|
|
};
|
|
}
|
|
|
|
return {
|
|
bannerTitle: "Filtro Face ID attivo",
|
|
bannerText: "Mostro <strong>{count}</strong> foto corrispondenti nella normale pagina gara.",
|
|
clearText: "Mostra tutte le foto della gara",
|
|
emptyText: "Nessuna foto FaceAI corrispondente e disponibile in questa vista della gara."
|
|
};
|
|
}
|
|
|
|
function updateFaceAiLegacyCount(visibleCount) {
|
|
var countValue = $("#faceAiPhotoCountValue");
|
|
if (!countValue.length) {
|
|
return;
|
|
}
|
|
|
|
countValue.text(String(visibleCount));
|
|
}
|
|
|
|
function escapeFaceAiAttribute(value) {
|
|
return String(value || "").replace(/&/g, "&").replace(/"/g, """);
|
|
}
|
|
|
|
function isFaceAiNumericPhotoId(value) {
|
|
return /^\d+$/.test(String(value || "").trim());
|
|
}
|
|
|
|
function getFaceAiLookupEndpoint() {
|
|
return "faceai_photo_lookup.jsp";
|
|
}
|
|
|
|
function getFaceAiGalleryLayoutOptions() {
|
|
var config = window.faceAiConfig || {};
|
|
if (config.galleryMode === "compact") {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
rowHeight: 150,
|
|
margins: 8
|
|
};
|
|
}
|
|
|
|
function refreshFaceAiLegacyGalleryLayout(gallery) {
|
|
var options;
|
|
|
|
if (!gallery || !gallery.length || typeof $.fn.justifiedGallery !== "function") {
|
|
return;
|
|
}
|
|
|
|
if (gallery.data("jg.controller")) {
|
|
gallery.justifiedGallery("destroy");
|
|
}
|
|
|
|
options = getFaceAiGalleryLayoutOptions();
|
|
if (options) {
|
|
gallery.justifiedGallery(options);
|
|
return;
|
|
}
|
|
|
|
gallery.justifiedGallery();
|
|
gallery.justifiedGallery("norewind");
|
|
return;
|
|
}
|
|
|
|
function normalizeFaceAiLookupToken(value) {
|
|
return String(value || "")
|
|
.toUpperCase()
|
|
.replace(/\\+/g, "/")
|
|
.replace(/\s+/g, "_")
|
|
.replace(/[^A-Z0-9._/-]+/g, "")
|
|
.replace(/^_+|_+$/g, "");
|
|
}
|
|
|
|
function collectFaceAiCheckpointTokens(value) {
|
|
var normalized = normalizeFaceAiLookupToken(value);
|
|
var tokens = {};
|
|
var current = normalized;
|
|
|
|
while (current) {
|
|
tokens[current] = true;
|
|
current = current.replace(/^\d+\./, "");
|
|
if (tokens[current]) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
current = normalized.replace(/^\d+\./, "");
|
|
while (current) {
|
|
tokens[current] = true;
|
|
if (current.indexOf("_") === -1) {
|
|
break;
|
|
}
|
|
current = current.replace(/_[^_]+$/, "");
|
|
}
|
|
|
|
return tokens;
|
|
}
|
|
|
|
function findFaceAiPointIdsForCheckpoint(checkpointLabel) {
|
|
var field = $("#id_puntoFoto");
|
|
var lookupTokens = collectFaceAiCheckpointTokens(checkpointLabel);
|
|
var ids = [];
|
|
|
|
if (!field.length || !Object.keys(lookupTokens).length) {
|
|
return ids;
|
|
}
|
|
|
|
field.find("option").each(function() {
|
|
var option = $(this);
|
|
var value = String(option.val() || "").trim();
|
|
var optionTokens;
|
|
var token;
|
|
|
|
if (!/^\d+$/.test(value)) {
|
|
return;
|
|
}
|
|
|
|
optionTokens = collectFaceAiCheckpointTokens(option.text());
|
|
for (token in optionTokens) {
|
|
if (optionTokens.hasOwnProperty(token) && lookupTokens[token]) {
|
|
ids.push(value);
|
|
return;
|
|
}
|
|
}
|
|
});
|
|
|
|
return ids;
|
|
}
|
|
|
|
function getFaceAiPhotoLookupData(photoKey) {
|
|
var value = String(photoKey || "").trim();
|
|
var normalizedPath = value.replace(/\\+/g, "/");
|
|
var segments = normalizedPath.split("/");
|
|
var fileName = segments.length ? String(segments[segments.length - 1] || "").trim() : "";
|
|
var checkpointLabel = segments.length > 1 ? String(segments[0] || "").trim() : "";
|
|
var raceId = String($("#id_gara").val() || "").trim();
|
|
var puntoFotoIds = checkpointLabel ? findFaceAiPointIdsForCheckpoint(checkpointLabel) : [];
|
|
|
|
return {
|
|
photoKey: value,
|
|
request: {
|
|
photoId: value,
|
|
normalizedPhotoId: normalizedPath,
|
|
fileName: fileName,
|
|
raceId: raceId,
|
|
checkpointLabel: checkpointLabel,
|
|
puntoFotoIds: puntoFotoIds.join(",")
|
|
}
|
|
};
|
|
}
|
|
|
|
function hideFaceAiLegacyPagination() {
|
|
$("nav[aria-label='paginatore']").hide();
|
|
$("#pageRow").closest(".col-md-3").hide();
|
|
}
|
|
|
|
function renderFaceAiLegacyBanner(state) {
|
|
var copy = getFaceAiFilterCopy();
|
|
var banner = $("#faceAiFilterBanner");
|
|
var message = copy.bannerText.replace("{count}", String(state.visibleCount));
|
|
|
|
if (!banner.length) {
|
|
var bannerHtml = ''
|
|
+ '<div class="col-12" id="faceAiFilterBannerWrap">'
|
|
+ '<div id="faceAiFilterBanner" class="alert alert-warning d-flex flex-column flex-md-row justify-content-between align-items-md-center mb-3" role="status">'
|
|
+ '<div class="mb-2 mb-md-0">'
|
|
+ '<strong id="faceAiFilterBannerTitle"></strong> '
|
|
+ '<span id="faceAiFilterBannerText"></span>'
|
|
+ '</div>'
|
|
+ '<button type="button" id="faceAiClearFilterButton" class="btn btn-sm btn-outline-dark"></button>'
|
|
+ '</div>'
|
|
+ '</div>';
|
|
|
|
var insertTarget = $("#faceAiResultsSummary").closest(".col-md-4").parent();
|
|
if (insertTarget.length) {
|
|
insertTarget.before(bannerHtml);
|
|
} else {
|
|
$(".container.my-3 .row.mb-5").first().prepend(bannerHtml);
|
|
}
|
|
|
|
banner = $("#faceAiFilterBanner");
|
|
}
|
|
|
|
$(document).off("click.faceAiClearFilter", "#faceAiClearFilterButton");
|
|
$(document).on("click.faceAiClearFilter", "#faceAiClearFilterButton", function() {
|
|
var activeState = window.faceAiMatchState || state;
|
|
if (activeState && activeState.storageKey) {
|
|
clearFaceAiStoredMatchPayload(activeState.storageKey);
|
|
}
|
|
window.location.href = activeState && activeState.clearUrl ? activeState.clearUrl : state.clearUrl;
|
|
});
|
|
|
|
$("#faceAiFilterBannerTitle").text(copy.bannerTitle);
|
|
$("#faceAiFilterBannerText").html(message);
|
|
$("#faceAiClearFilterButton").text(copy.clearText);
|
|
$("#faceAiEmptyResultsMessage").remove();
|
|
|
|
if (state.visibleCount > 0) {
|
|
return;
|
|
}
|
|
|
|
var emptyMessage = '<div class="col-12" id="faceAiEmptyResultsMessage"><div class="alert alert-light border mb-3">' + faceAiEscapeHtml(copy.emptyText) + '</div></div>';
|
|
var gallery = $("#demo");
|
|
if (gallery.length) {
|
|
gallery.closest(".col-md-10").before(emptyMessage);
|
|
}
|
|
}
|
|
|
|
function buildFaceAiLegacyPhotoCard(photoKey, legacyId, imageSrc) {
|
|
var safePhotoKey = escapeFaceAiAttribute(photoKey);
|
|
var safeLegacyId = escapeFaceAiAttribute(legacyId);
|
|
var safeImageSrc = escapeFaceAiAttribute(imageSrc);
|
|
var captionLabel = String(getCurrentLangValue() || "it").toLowerCase().indexOf("en") === 0 ? "Photo ID" : "ID foto";
|
|
|
|
return $(
|
|
'<a href="javascript:mostraFoto(' + safeLegacyId + ')" data-faceai-photo-id="' + safePhotoKey + '" data-faceai-legacy-id="' + safeLegacyId + '">' +
|
|
'<img src="' + safeImageSrc + '" alt="" class="thumb" />' +
|
|
'<div class="caption">' + captionLabel + ': ' + faceAiEscapeHtml(photoKey) + '</div>' +
|
|
'</a>'
|
|
);
|
|
}
|
|
|
|
function extractFaceAiImageSrc(htmlPayload) {
|
|
var parsedNodes = $.parseHTML(htmlPayload || "", document, true) || [];
|
|
var wrapper = $("<div></div>").append(parsedNodes);
|
|
var image = wrapper.find("img").first();
|
|
if (!image.length) {
|
|
return "";
|
|
}
|
|
|
|
return image.attr("src") || "";
|
|
}
|
|
|
|
function fetchFaceAiLegacyPhotoCard(photoKey) {
|
|
var lookupData = getFaceAiPhotoLookupData(photoKey);
|
|
|
|
return $.getJSON(getFaceAiLookupEndpoint(), lookupData.request).then(function(payload) {
|
|
if (!payload || !payload.found || !payload.legacyId || !payload.thumbSrc) {
|
|
return null;
|
|
}
|
|
|
|
return buildFaceAiLegacyPhotoCard(payload.photoId || lookupData.photoKey, payload.legacyId, payload.thumbSrc);
|
|
}, function() {
|
|
if (!isFaceAiNumericPhotoId(photoKey)) {
|
|
return null;
|
|
}
|
|
|
|
return $.get("Foto2.abl?cmd=mostraFoto&id_foto=" + encodeURIComponent(photoKey)).then(function(htmlPayload) {
|
|
var imageSrc = extractFaceAiImageSrc(htmlPayload);
|
|
if (!imageSrc) {
|
|
return null;
|
|
}
|
|
|
|
return buildFaceAiLegacyPhotoCard(photoKey, photoKey, imageSrc);
|
|
}, function() {
|
|
return null;
|
|
});
|
|
});
|
|
}
|
|
|
|
function cloneFaceAiExistingPhotoCard(item) {
|
|
if (!item || !item.length) {
|
|
return null;
|
|
}
|
|
|
|
var clone = item.clone(true, true);
|
|
clone.attr("data-faceai-photo-id", item.attr("data-faceai-photo-id") || "");
|
|
clone.attr("data-faceai-legacy-id", item.attr("data-faceai-legacy-id") || "");
|
|
return clone;
|
|
}
|
|
|
|
function collectFaceAiExistingPhotoCards(gallery, matchState) {
|
|
var cardsById = {};
|
|
|
|
gallery.find("[data-faceai-photo-id]").each(function() {
|
|
var item = $(this);
|
|
var photoId = String(item.attr("data-faceai-photo-id") || "").trim();
|
|
if (!photoId || !matchState.photoIdSet[photoId] || cardsById[photoId]) {
|
|
return;
|
|
}
|
|
|
|
cardsById[photoId] = cloneFaceAiExistingPhotoCard(item);
|
|
});
|
|
|
|
return cardsById;
|
|
}
|
|
|
|
function finalizeFaceAiLegacyGallery(gallery, matchState, cards) {
|
|
var visibleCards = [];
|
|
var index;
|
|
var activeRequestId = window.faceAiLegacyGalleryRequestId || 0;
|
|
|
|
if (matchState.requestId !== activeRequestId) {
|
|
return;
|
|
}
|
|
|
|
gallery.empty();
|
|
for (index = 0; index < cards.length; index += 1) {
|
|
if (!cards[index] || !cards[index].length) {
|
|
continue;
|
|
}
|
|
visibleCards.push(cards[index]);
|
|
gallery.append(cards[index]);
|
|
}
|
|
|
|
matchState.visibleCount = visibleCards.length;
|
|
window.faceAiMatchState = matchState;
|
|
updateFaceAiLegacyCount(matchState.visibleCount);
|
|
renderFaceAiLegacyBanner(matchState);
|
|
refreshFaceAiLegacyGalleryLayout(gallery);
|
|
|
|
$(document).trigger("faceai:gallery-ready", [matchState]);
|
|
|
|
logFaceAiDebug("Applied legacy FaceAI filter", {
|
|
matchCount: matchState.matchCount,
|
|
visibleCount: matchState.visibleCount,
|
|
photoIds: matchState.photoIds
|
|
});
|
|
}
|
|
|
|
function loadFaceAiLegacyGallery(gallery, matchState) {
|
|
var existingCards = collectFaceAiExistingPhotoCards(gallery, matchState);
|
|
var orderedCards = [];
|
|
var index;
|
|
|
|
updateFaceAiLegacyCount(0);
|
|
gallery.empty().append('<div class="faceai-loading text-center w-100 py-4">FaceAI loading...</div>');
|
|
|
|
for (index = 0; index < matchState.photoIds.length; index += 1) {
|
|
(function(photoId) {
|
|
if (existingCards[photoId]) {
|
|
orderedCards.push($.Deferred().resolve(existingCards[photoId]).promise());
|
|
return;
|
|
}
|
|
|
|
orderedCards.push(fetchFaceAiLegacyPhotoCard(photoId));
|
|
}(matchState.photoIds[index]));
|
|
}
|
|
|
|
$.when.apply($, orderedCards).then(function() {
|
|
var resolvedCards = orderedCards.length === 1 ? [arguments[0]] : Array.prototype.slice.call(arguments);
|
|
finalizeFaceAiLegacyGallery(gallery, matchState, resolvedCards);
|
|
}, function() {
|
|
finalizeFaceAiLegacyGallery(gallery, matchState, []);
|
|
});
|
|
}
|
|
|
|
function prepareFaceAiLegacyRacePage() {
|
|
var matchState = getFaceAiMatchState();
|
|
var gallery = $("#demo");
|
|
var preparationKey;
|
|
if (!matchState || !gallery.length) {
|
|
return null;
|
|
}
|
|
|
|
preparationKey = window.location.pathname + "?" + window.location.search;
|
|
if (window.faceAiLegacyPreparationKey === preparationKey) {
|
|
return window.faceAiMatchState || matchState;
|
|
}
|
|
|
|
window.faceAiLegacyPreparationKey = preparationKey;
|
|
window.faceAiLegacyGalleryRequestId = (window.faceAiLegacyGalleryRequestId || 0) + 1;
|
|
matchState.requestId = window.faceAiLegacyGalleryRequestId;
|
|
matchState.visibleCount = 0;
|
|
hideFaceAiLegacyPagination();
|
|
renderFaceAiLegacyBanner(matchState);
|
|
loadFaceAiLegacyGallery(gallery, matchState);
|
|
|
|
return matchState;
|
|
}
|
|
|
|
function initFaceAiLegacyRacePage() {
|
|
var directReturnState = getFaceAiDirectReturnState();
|
|
|
|
if (directReturnState) {
|
|
hydrateFaceAiDirectReturn();
|
|
return null;
|
|
}
|
|
|
|
return prepareFaceAiLegacyRacePage();
|
|
}
|
|
|
|
function buildFaceAiLaunchUrl() {
|
|
var raceId = $("#id_gara").val() || "";
|
|
var raceSlug = $("#garaDesc").val() || "";
|
|
var raceName = $("h1.my-4").last().text().replace(/\s+/g, " ").trim();
|
|
var raceYear = getFaceAiStorageValue("faceAiRaceYear", "year");
|
|
var raceMonthFolder = getFaceAiStorageValue("faceAiRaceMonthFolder", "monthFolder");
|
|
var raceFolder = getFaceAiStorageValue("faceAiRaceFolder", "raceFolder");
|
|
var raceStorageRelativeDir = $("#faceAiRaceStorageRelativeDir").val() || [raceYear, raceMonthFolder, raceFolder].filter(Boolean).join("/");
|
|
var lang = getCurrentLangValue();
|
|
var handoffUrl = (window.faceAiSimulator && window.faceAiSimulator.handoffUrl) || "faceai_handoff.php";
|
|
var returnUrl = stripFaceAiStateFromUrl((window.faceAiSimulator && window.faceAiSimulator.returnUrl) || window.location.href);
|
|
var query = [
|
|
"raceId=" + encodeURIComponent(raceId),
|
|
"raceSlug=" + encodeURIComponent(raceSlug),
|
|
"raceName=" + encodeURIComponent(raceName),
|
|
"raceYear=" + encodeURIComponent(raceYear),
|
|
"raceMonthFolder=" + encodeURIComponent(raceMonthFolder),
|
|
"raceFolder=" + encodeURIComponent(raceFolder),
|
|
"raceStorageRelativeDir=" + encodeURIComponent(raceStorageRelativeDir),
|
|
"lang=" + encodeURIComponent(lang),
|
|
"returnUrl=" + encodeURIComponent(returnUrl)
|
|
];
|
|
|
|
if (window.faceAiSimulator && window.faceAiSimulator.devUserId) {
|
|
query.push("devUserId=" + encodeURIComponent(window.faceAiSimulator.devUserId));
|
|
}
|
|
if (window.faceAiSimulator && window.faceAiSimulator.devDisplayName) {
|
|
query.push("devDisplayName=" + encodeURIComponent(window.faceAiSimulator.devDisplayName));
|
|
}
|
|
if (window.faceAiSimulator && window.faceAiSimulator.devEmail) {
|
|
query.push("devEmail=" + encodeURIComponent(window.faceAiSimulator.devEmail));
|
|
}
|
|
if (window.faceAiSimulator && window.faceAiSimulator.devMembershipStatus) {
|
|
query.push("devMembershipStatus=" + encodeURIComponent(window.faceAiSimulator.devMembershipStatus));
|
|
}
|
|
|
|
logFaceAiDebug("Legacy launch payload prepared", {
|
|
query: query.slice(0),
|
|
raceId: raceId,
|
|
raceSlug: raceSlug,
|
|
raceName: raceName
|
|
});
|
|
|
|
return handoffUrl + "?" + query.join("&");
|
|
}
|
|
|
|
function launchFaceAi() {
|
|
logFaceAiDebug("Redirecting to FaceAI handoff");
|
|
$("body").addClass("loading");
|
|
window.location.href = buildFaceAiLaunchUrl();
|
|
return false;
|
|
}
|
|
|
|
function clearLegacyLoadingState() {
|
|
$("body").removeClass("loading");
|
|
}
|
|
|
|
function shouldClearLegacyLoadingOnRestore(event) {
|
|
if (event && event.persisted) {
|
|
return true;
|
|
}
|
|
|
|
if (window.performance && typeof window.performance.getEntriesByType === "function") {
|
|
var entries = window.performance.getEntriesByType("navigation");
|
|
if (entries && entries.length && entries[0].type === "back_forward") {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function restoreLegacyPageAfterHistoryNavigation(event) {
|
|
if (!shouldClearLegacyLoadingOnRestore(event)) {
|
|
return;
|
|
}
|
|
|
|
clearLegacyLoadingState();
|
|
logFaceAiDebug("Cleared legacy loading state after history navigation");
|
|
}
|
|
|
|
function initFaceAiRaceSearchButton() {
|
|
var select = $("#tipoPuntoFoto");
|
|
if (!select.length || $("#faceaiLaunchButton").length || !faceAiFeatureEnabled()) {
|
|
return;
|
|
}
|
|
|
|
var inputGroup = select.closest(".input-group");
|
|
var renderTarget = inputGroup.length ? inputGroup : select.parent();
|
|
var currentValue = select.val() || "";
|
|
|
|
if (!renderTarget.length) {
|
|
return;
|
|
}
|
|
|
|
select.off("change");
|
|
select.remove();
|
|
|
|
if (!$("#tipoPuntoFoto").length) {
|
|
renderTarget.append('<input type="hidden" name="tipoPuntoFoto" id="tipoPuntoFoto" value="' + currentValue.replace(/"/g, '"') + '">');
|
|
}
|
|
|
|
renderTarget.append('<button type="button" id="faceaiLaunchButton" class="btn btn-warning btn-block text-uppercase" onclick="return launchFaceAi();"><i class="fa fa-camera-retro" aria-hidden="true"></i> Face ID</button>');
|
|
}
|
|
|
|
function searching() {
|
|
//gara%201_gara-1---2.html
|
|
$("body").addClass("loading");
|
|
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "-" + $("#id_puntoFoto").val() + "-" + getTipoPuntoFotoValue() + "-" + $("#pageRow").val() + "-1-"+$("#pettorale").val()+"-"+getCurrentLangValue()+".html";
|
|
//alert(theSvlt);
|
|
location.href = theSvlt;
|
|
|
|
}
|
|
function searchingTPF() {
|
|
//gara%201_gara-1---2.html
|
|
|
|
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "--" + getTipoPuntoFotoValue() + "-" + $("#pageRow").val() + "-1.html";
|
|
//alert(theSvlt);
|
|
location.href = theSvlt;
|
|
|
|
}
|
|
function searchingPF() {
|
|
//gara%201_gara-1---2.html
|
|
|
|
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "-" + $("#id_puntoFoto").val() + "--" + $("#pageRow").val() + "-1.html";
|
|
//alert(theSvlt);
|
|
location.href = theSvlt;
|
|
|
|
}
|
|
function loginFCR() {
|
|
//FACCIO IL SUBMIT
|
|
var f = document.frmLogin;
|
|
if (Ab.validateForm('login', 'Login', 'R', 'pwd', 'password', 'R')) {
|
|
$("body").addClass("loading");
|
|
f.cmdIU.value = "check";
|
|
f.act.value = "";
|
|
f.thePage.value = window.location.href;
|
|
f.action = "Logon.abl";
|
|
f.submit();
|
|
}
|
|
|
|
}
|
|
|
|
function mostraFoto(l_id) {
|
|
//alert("Foto2.abl?cmd=mostraFoto&id_foto=" + l_id);
|
|
$("#fotoView").load("Foto2.abl?cmd=mostraFoto&id_foto=" + l_id);
|
|
|
|
$("#ModalLog").modal("show");
|
|
|
|
}
|
|
/***************************************************/
|
|
/***************************************************/
|
|
/* PAGINA dati personali DOCUMENTOCR */
|
|
/***************************************************/
|
|
/***************************************************/
|
|
function loginDCR() {
|
|
//FACCIO IL SUBMIT
|
|
var f = document.frmLogin;
|
|
if (Ab.validateForm('login', 'Login', 'R', 'pwd', 'password', 'R')) {
|
|
$("body").addClass("loading");
|
|
f.cmdIU.value = "check";
|
|
f.act.value = ""
|
|
f.action = "Logon.abl";
|
|
f.submit();
|
|
}
|
|
|
|
}
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
/*** invia coupon
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
|
|
function inviaCoupon() {
|
|
//FACCIO IL SUBMIT
|
|
|
|
var f = document.frmCoupon;
|
|
if (Ab.validateForm('coupon', 'Coupon', 'R')) {
|
|
$("body").addClass("loading");
|
|
f.cmd.value = "inviaCoupon";
|
|
f.act.value = ""
|
|
f.action = "Ordine.abl";
|
|
f.submit();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
/*** LOST PASSWORD
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
|
|
function lostPwdForm(theForm) {
|
|
var f = theForm;
|
|
var l_lang = $("#lang").val();
|
|
if (Ab.validateForm('lostPwdEmail', 'Email di recupero', 'RisEmail')) {
|
|
$("body").addClass("loading");
|
|
f.action = "Users.abl";
|
|
f.cmd.value = "lostPassword";
|
|
f.act.value = "";
|
|
f.submit();
|
|
}
|
|
}
|
|
|
|
function lostPwdCheckOut() {
|
|
lostPwdForm(document.cart);
|
|
}
|
|
|
|
function lostPwdLogon() {
|
|
lostPwdForm(document.frmLogin);
|
|
}
|
|
|
|
/***************************************************/
|
|
/***************************************************/
|
|
/* PAGINA registrazione */
|
|
/***************************************************/
|
|
/***************************************************/
|
|
function controlloRegistrazione() {
|
|
//alert('pio');
|
|
var f = document.dettaglio;
|
|
//if (Ab.validateForm('login', 'Login', 'R', 'pwd', 'Password', 'R', 'nome', 'Nome', 'R', 'cognome', 'Cognome', 'R', 'eMail', 'Indirizzo e-mail', 'RisEmail', 'citta', 'Citta', 'R', 'cap', 'Cap', 'R', 'indirizzo', 'Indirizzo', 'R', 'numeroCivico', 'Numero Civico', 'R', 'codFisc', 'Codice Fiscale', 'R'))
|
|
if (Ab.validateForm('login', 'Login', 'R', 'pwd', 'Password', 'R', 'nome', 'Nome', 'R', 'cognome', 'Cognome', 'R', 'eMail', 'Indirizzo e-mail', 'RisEmail', 'citta', 'Citta', 'R', 'cap', 'Cap', 'R', 'indirizzo', 'Indirizzo', 'R', 'numeroCivico', 'Numero Civico', 'R'))
|
|
// if(true)
|
|
{
|
|
|
|
//checkboxes
|
|
|
|
|
|
if (f.ckFlgPrivTrattamento.checked) f.flgPrivTrattamento.value = "1";
|
|
else f.flgPrivTrattamento.value = "0";
|
|
if (f.ckFlgPrivComunicazione.checked) f.flgPrivComunicazione.value = "1";
|
|
else f.flgPrivComunicazione.value = "0";
|
|
if (f.ckflgMl.checked) f.flgMl.value = "1";
|
|
else f.flgMl.value = "0";
|
|
//privacy
|
|
|
|
if (f.flgPrivTrattamento.value == "1")
|
|
return true;
|
|
else {
|
|
alert("Attenzione!. E' obbligatorio fornire il consenso al trattamento dei dati comuni");
|
|
return false;
|
|
}
|
|
if (f.flgPrivComunicazione.value == "1")
|
|
return true;
|
|
else {
|
|
alert("Attenzione!. E' obbligatorio fornire il consenso alle norme di utilizzo delle immagini");
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
|
|
} else
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
/*** VISTA COMPATTA E ESTESA FOTOCR
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
|
|
function vistaCompatta() {
|
|
|
|
//fetch(servlet, command, divList, postProcess, async, type)
|
|
Ab.fetch("Foto2.abl", "cmd=vistaCompatta", "vis", null, 1);
|
|
var thePage= window.location.href;
|
|
|
|
location.href = thePage;
|
|
}
|
|
|
|
function vistaEstesa() {
|
|
|
|
Ab.fetch("Foto2.abl", "cmd=vistaEstesa", "vis", null, 1);
|
|
var thePage= window.location.href;
|
|
|
|
location.href = thePage;
|
|
}
|
|
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
/*** go page sopra
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
function goPage()
|
|
{
|
|
//richiamo anche un metodo che carica i checkBox e i checkRadio
|
|
var pnGo=$("#pageNumberGo").val(),
|
|
pn=$("#totPageNumber").val();
|
|
|
|
|
|
if(parseFloat(pnGo)<= parseFloat(pn))
|
|
{
|
|
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "-" + $("#id_puntoFoto").val() + "-" + getTipoPuntoFotoValue() + "-" + $("#pageRow").val() + "-"+pnGo+".html";
|
|
//alert(theSvlt);
|
|
location.href = theSvlt;
|
|
}
|
|
else
|
|
alert('Errore!!');
|
|
}
|
|
|
|
$(function() {
|
|
clearLegacyLoadingState();
|
|
initFaceAiLegacyRacePage();
|
|
initFaceAiRaceSearchButton();
|
|
initFaceAiErrorModal();
|
|
logFaceAiDebug("Legacy race page ready");
|
|
});
|
|
|
|
if (window.addEventListener) {
|
|
window.addEventListener("pageshow", restoreLegacyPageAfterHistoryNavigation);
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
/*** fase INIZIALE pagamento paypal
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
function startPayPal()
|
|
{
|
|
var f = document.paypal;
|
|
//if (confirm(f.seiSicuro.value))
|
|
{
|
|
{
|
|
$("body").addClass("loading");
|
|
f.submit();
|
|
}
|
|
}
|
|
|
|
}
|
|
function startPayPal1()
|
|
{
|
|
$("#amt").val("20,00");
|
|
startPayPal();
|
|
|
|
}
|
|
function startPayPal3()
|
|
{
|
|
$("#amt").val("40,00");
|
|
startPayPal();
|
|
|
|
}
|
|
function startPayPal20f()
|
|
{
|
|
$("#amt").val("5,00");
|
|
startPayPal();
|
|
|
|
}
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
/*** fase finale pagamento paypal
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
function doPayPal()
|
|
{
|
|
var f = document.cart;
|
|
//if (confirm(f.seiSicuro.value))
|
|
{
|
|
|
|
{
|
|
$("body").addClass("loading");
|
|
f.action="PayPalDoPayment.abl";
|
|
f.cmd.value="doPayment";
|
|
f.submit();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
/*** faggiungo click thru sull'allegato immagine
|
|
/*************************************************************/
|
|
/*************************************************************/
|
|
function addClickThroughAttach(id)
|
|
{
|
|
//alert('aaaa News.abl?cmd=addClickThroughAttach&id='+id);
|
|
Ab.fetch4("News.abl", "cmd=addClickThroughAttach&id="+id, null, null, true, null) ;
|
|
//Ab.fetch("News.abl", "cmd=addClickThroughAttach&id="+id, "", null, 1);
|
|
|
|
}
|