feat: Add FaceAI integration with handoff and return functionality

- Introduced a new workspace for FaceAI in package.json.
- Implemented FaceAI handoff logic in faceai_handoff.php, including identity verification and token signing.
- Created faceai_return.php to handle return requests from FaceAI, validating tokens and forwarding results.
- Developed faceai_simulator.php and faceai_simulator_view.php for simulating the FaceAI interface with demo photos.
- Enhanced rus-ecom-240621.js to support new FaceAI features, including dynamic URL building and button integration.
- Added faceai_config.php for configuration management, including environment variable handling and utility functions.
- Updated HTML structure and styles in simulator view for better user experience.
This commit is contained in:
MaddoScientisto 2026-04-07 19:53:40 +02:00
commit da362c201f
31 changed files with 4511 additions and 60 deletions

View file

@ -96,10 +96,89 @@ function searchGara() {
/* 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 buildFaceAiLaunchUrl() {
var raceId = $("#id_gara").val() || "";
var raceSlug = $("#garaDesc").val() || "";
var raceName = $("h1.my-4").last().text().replace(/\s+/g, " ").trim();
var lang = getCurrentLangValue();
var handoffUrl = (window.faceAiSimulator && window.faceAiSimulator.handoffUrl) || "faceai_handoff.php";
var returnUrl = (window.faceAiSimulator && window.faceAiSimulator.returnUrl) || window.location.href;
var query = [
"raceId=" + encodeURIComponent(raceId),
"raceSlug=" + encodeURIComponent(raceSlug),
"raceName=" + encodeURIComponent(raceName),
"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));
}
return handoffUrl + "?" + query.join("&");
}
function launchFaceAi() {
$("body").addClass("loading");
window.location.href = buildFaceAiLaunchUrl();
return false;
}
function initFaceAiRaceSearchButton() {
var select = $("#tipoPuntoFoto");
if (!select.length || $("#faceaiLaunchButton").length) {
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, '&quot;') + '">');
}
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() + "-" + $("#tipoPuntoFoto").val() + "-" + $("#pageRow").val() + "-1-"+$("#pettorale").val()+"-"+$("#lang").val()+".html";
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "-" + $("#id_puntoFoto").val() + "-" + getTipoPuntoFotoValue() + "-" + $("#pageRow").val() + "-1-"+$("#pettorale").val()+"-"+getCurrentLangValue()+".html";
//alert(theSvlt);
location.href = theSvlt;
@ -107,7 +186,7 @@ function searching() {
function searchingTPF() {
//gara%201_gara-1---2.html
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "--" + $("#tipoPuntoFoto").val() + "-" + $("#pageRow").val() + "-1.html";
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "--" + getTipoPuntoFotoValue() + "-" + $("#pageRow").val() + "-1.html";
//alert(theSvlt);
location.href = theSvlt;
@ -288,7 +367,7 @@ function goPage()
if(parseFloat(pnGo)<= parseFloat(pn))
{
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "-" + $("#id_puntoFoto").val() + "-" + $("#tipoPuntoFoto").val() + "-" + $("#pageRow").val() + "-"+pnGo+".html";
theSvlt = $("#garaDesc").val() + "_gara-" + $("#id_gara").val() + "-" + $("#id_puntoFoto").val() + "-" + getTipoPuntoFotoValue() + "-" + $("#pageRow").val() + "-"+pnGo+".html";
//alert(theSvlt);
location.href = theSvlt;
}
@ -296,6 +375,10 @@ function goPage()
alert('Errore!!');
}
$(function() {
initFaceAiRaceSearchButton();
});