Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse files- templates/index.html +8 -29
templates/index.html
CHANGED
|
@@ -149,19 +149,19 @@
|
|
| 149 |
}
|
| 150 |
}
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
|
|
|
| 154 |
const imgElement = document.getElementById(`preset-${presetNumber}-${target}`);
|
| 155 |
-
const imagePath = imgElement.getAttribute('src');
|
| 156 |
-
|
| 157 |
|
| 158 |
fetch(imagePath)
|
| 159 |
.then(res => {
|
| 160 |
-
if (!res.ok) throw new Error(`
|
| 161 |
return res.blob();
|
| 162 |
})
|
| 163 |
.then(blob => {
|
| 164 |
-
const fileName = imagePath.split('/').pop();
|
| 165 |
const file = new File([blob], fileName, { type: blob.type });
|
| 166 |
if (target === 1) {
|
| 167 |
file1 = file;
|
|
@@ -176,34 +176,13 @@ function selectPreset(presetNumber, target) {
|
|
| 176 |
}
|
| 177 |
})
|
| 178 |
.catch(err => {
|
| 179 |
-
console.error(
|
|
|
|
| 180 |
})
|
| 181 |
.then(() => checkReadyToCompare());
|
| 182 |
}
|
| 183 |
|
| 184 |
|
| 185 |
-
###____
|
| 186 |
-
|
| 187 |
-
### function selectPreset(presetNumber, target) {
|
| 188 |
-
### fetch(`/static/${presetNumber}.webp`)
|
| 189 |
-
### .then(res => res.blob())
|
| 190 |
-
### .then(blob => {
|
| 191 |
-
### const file = new File([blob], `preset${presetNumber}.webp`, { type: blob.type });
|
| 192 |
-
### if (target === 1) {
|
| 193 |
-
### file1 = file;
|
| 194 |
-
### updatePreview(blob, 1);
|
| 195 |
-
### resetSelection(1);
|
| 196 |
-
### document.getElementById(`preset-${presetNumber}-1`).classList.add('selected');
|
| 197 |
-
### } else {
|
| 198 |
-
### file2 = file;
|
| 199 |
-
### updatePreview(blob, 2);
|
| 200 |
-
### resetSelection(2);
|
| 201 |
-
### document.getElementById(`preset-${presetNumber}-2`).classList.add('selected');
|
| 202 |
-
### }
|
| 203 |
-
### })
|
| 204 |
-
### .then(() => checkReadyToCompare());
|
| 205 |
-
### }
|
| 206 |
-
|
| 207 |
function updatePreview(blob, target) {
|
| 208 |
const reader = new FileReader();
|
| 209 |
reader.onload = (event) => {
|
|
|
|
| 149 |
}
|
| 150 |
}
|
| 151 |
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
function selectPreset(presetNumber, target) {
|
| 155 |
const imgElement = document.getElementById(`preset-${presetNumber}-${target}`);
|
| 156 |
+
const imagePath = imgElement.getAttribute('src'); // Récupère le chemin exact
|
| 157 |
+
const fileName = imagePath.split('/').pop(); // Extrait le nom du fichier
|
| 158 |
|
| 159 |
fetch(imagePath)
|
| 160 |
.then(res => {
|
| 161 |
+
if (!res.ok) throw new Error(`Impossible de charger ${fileName}`);
|
| 162 |
return res.blob();
|
| 163 |
})
|
| 164 |
.then(blob => {
|
|
|
|
| 165 |
const file = new File([blob], fileName, { type: blob.type });
|
| 166 |
if (target === 1) {
|
| 167 |
file1 = file;
|
|
|
|
| 176 |
}
|
| 177 |
})
|
| 178 |
.catch(err => {
|
| 179 |
+
console.error('Erreur de chargement de l’image :', err);
|
| 180 |
+
alert(err.message);
|
| 181 |
})
|
| 182 |
.then(() => checkReadyToCompare());
|
| 183 |
}
|
| 184 |
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
function updatePreview(blob, target) {
|
| 187 |
const reader = new FileReader();
|
| 188 |
reader.onload = (event) => {
|