TheFrenchDemos commited on
Commit
0cb5e39
·
verified ·
1 Parent(s): 646b872

Update templates/index.html

Browse files

la sélection ne provoque plus d'affichage dans la zone de présélection
-> nouvelle version de la fonction selectPreset

Files changed (1) hide show
  1. templates/index.html +11 -3
templates/index.html CHANGED
@@ -150,12 +150,16 @@
150
  }
151
 
152
  ###___
153
- function selectPreset(presetNumber, target) {
154
  const imgElement = document.getElementById(`preset-${presetNumber}-${target}`);
155
- const imagePath = imgElement.src;
 
156
 
157
  fetch(imagePath)
158
- .then(res => res.blob())
 
 
 
159
  .then(blob => {
160
  const fileName = imagePath.split('/').pop();
161
  const file = new File([blob], fileName, { type: blob.type });
@@ -171,9 +175,13 @@
171
  imgElement.classList.add('selected');
172
  }
173
  })
 
 
 
174
  .then(() => checkReadyToCompare());
175
  }
176
 
 
177
  ###____
178
 
179
  ### function selectPreset(presetNumber, target) {
 
150
  }
151
 
152
  ###___
153
+ function selectPreset(presetNumber, target) {
154
  const imgElement = document.getElementById(`preset-${presetNumber}-${target}`);
155
+ const imagePath = imgElement.getAttribute('src'); // Chemin relatif
156
+ console.log("Fetching image from:", imagePath);
157
 
158
  fetch(imagePath)
159
+ .then(res => {
160
+ if (!res.ok) throw new Error(`Failed to load image: ${res.statusText}`);
161
+ return res.blob();
162
+ })
163
  .then(blob => {
164
  const fileName = imagePath.split('/').pop();
165
  const file = new File([blob], fileName, { type: blob.type });
 
175
  imgElement.classList.add('selected');
176
  }
177
  })
178
+ .catch(err => {
179
+ console.error("Error loading image:", err);
180
+ })
181
  .then(() => checkReadyToCompare());
182
  }
183
 
184
+
185
  ###____
186
 
187
  ### function selectPreset(presetNumber, target) {