fixed quotations
This commit is contained in:
+32
-19
@@ -1,19 +1,21 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// Funzione per caricare il contenuto del popup
|
||||
async function loadPopupContent(iddatadb) {
|
||||
async function loadPopupContent(iddatadb, idquotations) {
|
||||
const popupContent = document.getElementById("popupContent");
|
||||
if (!popupContent) {
|
||||
console.error("Elemento popupContent non trovato");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await fetch(
|
||||
`photos_popup.php?iddatadb=${iddatadb}`,
|
||||
);
|
||||
const endpoint = idquotations
|
||||
? `photos_popup.php?idquotations=${idquotations}`
|
||||
: `photos_popup.php?iddatadb=${iddatadb}`;
|
||||
console.log("Caricamento popup da:", endpoint);
|
||||
const response = await fetch(endpoint);
|
||||
if (!response.ok)
|
||||
throw new Error("Errore nella risposta del server");
|
||||
popupContent.innerHTML = await response.text();
|
||||
attachPhotoEventListeners(iddatadb);
|
||||
attachPhotoEventListeners(iddatadb, idquotations);
|
||||
} catch (error) {
|
||||
popupContent.innerHTML = `<p>Errore durante il caricamento: ${error.message}</p>`;
|
||||
console.error("Errore in loadPopupContent:", error);
|
||||
@@ -21,7 +23,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
}
|
||||
|
||||
// Funzione per gestire la webcam
|
||||
function setupWebcam(iddatadb) {
|
||||
function setupWebcam(iddatadb, idquotations) {
|
||||
const openWebcamBtn = document.getElementById("openWebcamBtn");
|
||||
const webcamArea = document.getElementById("webcamArea");
|
||||
const webcamVideo = document.getElementById("webcamVideo");
|
||||
@@ -158,7 +160,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
if (loader) {
|
||||
loader.style.display = "flex";
|
||||
}
|
||||
await handleFiles([file], iddatadb);
|
||||
await handleFiles([file], iddatadb, idquotations);
|
||||
if (stream) {
|
||||
stream.getTracks().forEach((track) => track.stop());
|
||||
stream = null;
|
||||
@@ -171,7 +173,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
});
|
||||
}
|
||||
|
||||
async function handleFiles(files, iddatadb) {
|
||||
async function handleFiles(files, iddatadb, idquotations) {
|
||||
const loader = document.getElementById("loader");
|
||||
if (!loader) {
|
||||
console.error("Elemento loader non trovato");
|
||||
@@ -193,7 +195,12 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("photo", file);
|
||||
formData.append("iddatadb", iddatadb);
|
||||
if (idquotations) {
|
||||
formData.append("idquotations", idquotations);
|
||||
} else {
|
||||
formData.append("iddatadb", iddatadb);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch("upload_photo.php", {
|
||||
method: "POST",
|
||||
@@ -201,7 +208,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
loadPopupContent(iddatadb);
|
||||
loadPopupContent(iddatadb, idquotations);
|
||||
} else {
|
||||
alert("Errore durante il caricamento: " + result.message);
|
||||
}
|
||||
@@ -213,7 +220,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
}
|
||||
}
|
||||
|
||||
function attachPhotoEventListeners(iddatadb) {
|
||||
function attachPhotoEventListeners(iddatadb, idquotations) {
|
||||
const dropArea = document.getElementById("dropArea");
|
||||
const photoInput = document.getElementById("photoInput");
|
||||
const photosModal = document.getElementById("photosModal");
|
||||
@@ -257,7 +264,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
(e) => {
|
||||
const files = e.dataTransfer.files;
|
||||
if (files.length > 0) {
|
||||
handleFiles(files, iddatadb);
|
||||
handleFiles(files, iddatadb, idquotations);
|
||||
}
|
||||
},
|
||||
false,
|
||||
@@ -276,7 +283,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
(e) => {
|
||||
const files = e.target.files;
|
||||
if (files.length > 0) {
|
||||
handleFiles(files, iddatadb);
|
||||
handleFiles(files, iddatadb, idquotations);
|
||||
}
|
||||
e.target.value = "";
|
||||
},
|
||||
@@ -298,7 +305,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
loadPopupContent(iddatadb);
|
||||
loadPopupContent(iddatadb, idquotations);
|
||||
} else {
|
||||
alert(
|
||||
"Errore durante l'eliminazione: " +
|
||||
@@ -336,7 +343,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
}
|
||||
});
|
||||
|
||||
setupWebcam(iddatadb);
|
||||
setupWebcam(iddatadb, idquotations);
|
||||
|
||||
const createCollageBtn = document.getElementById("createCollageBtn");
|
||||
if (createCollageBtn) {
|
||||
@@ -869,9 +876,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
type: "image/jpeg",
|
||||
});
|
||||
|
||||
await handleFiles([file], iddatadb);
|
||||
await handleFiles([file], iddatadb, idquotations);
|
||||
document.getElementById("collageModal").style.display = "none";
|
||||
loadPopupContent(iddatadb);
|
||||
loadPopupContent(iddatadb, idquotations);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -992,8 +999,14 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
if (photosButtons.length && photosModal && closeBtn) {
|
||||
photosButtons.forEach((button) => {
|
||||
button.addEventListener("click", function () {
|
||||
const iddatadb = this.getAttribute("data-iddatadb");
|
||||
loadPopupContent(iddatadb);
|
||||
const iddatadb = this.getAttribute("data-iddatadb") || null;
|
||||
const idquotations =
|
||||
this.getAttribute("data-idquotations") || null;
|
||||
console.log("Apertura modale foto con:", {
|
||||
iddatadb,
|
||||
idquotations,
|
||||
});
|
||||
loadPopupContent(iddatadb, idquotations);
|
||||
photosModal.style.display = "block";
|
||||
document.querySelector(".overlay").style.display = "none";
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user