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

Update templates/index.html

Browse files

cliquer sur "retour vers le futur" provoque l'affichage de "rose"
changement complet de la fonction selectPreset

Files changed (1) hide show
  1. templates/index.html +46 -19
templates/index.html CHANGED
@@ -149,25 +149,52 @@
149
  }
150
  }
151
 
152
- function selectPreset(presetNumber, target) {
153
- fetch(`/static/${presetNumber}.webp`)
154
- .then(res => res.blob())
155
- .then(blob => {
156
- const file = new File([blob], `preset${presetNumber}.webp`, { type: blob.type });
157
- if (target === 1) {
158
- file1 = file;
159
- updatePreview(blob, 1);
160
- resetSelection(1);
161
- document.getElementById(`preset-${presetNumber}-1`).classList.add('selected');
162
- } else {
163
- file2 = file;
164
- updatePreview(blob, 2);
165
- resetSelection(2);
166
- document.getElementById(`preset-${presetNumber}-2`).classList.add('selected');
167
- }
168
- })
169
- .then(() => checkReadyToCompare());
170
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  function updatePreview(blob, target) {
173
  const reader = new FileReader();
 
149
  }
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 });
162
+ if (target === 1) {
163
+ file1 = file;
164
+ updatePreview(blob, 1);
165
+ resetSelection(1);
166
+ imgElement.classList.add('selected');
167
+ } else {
168
+ file2 = file;
169
+ updatePreview(blob, 2);
170
+ resetSelection(2);
171
+ imgElement.classList.add('selected');
172
+ }
173
+ })
174
+ .then(() => checkReadyToCompare());
175
+ }
176
+
177
+ ###____
178
+
179
+ ### function selectPreset(presetNumber, target) {
180
+ ### fetch(`/static/${presetNumber}.webp`)
181
+ ### .then(res => res.blob())
182
+ ### .then(blob => {
183
+ ### const file = new File([blob], `preset${presetNumber}.webp`, { type: blob.type });
184
+ ### if (target === 1) {
185
+ ### file1 = file;
186
+ ### updatePreview(blob, 1);
187
+ ### resetSelection(1);
188
+ ### document.getElementById(`preset-${presetNumber}-1`).classList.add('selected');
189
+ ### } else {
190
+ ### file2 = file;
191
+ ### updatePreview(blob, 2);
192
+ ### resetSelection(2);
193
+ ### document.getElementById(`preset-${presetNumber}-2`).classList.add('selected');
194
+ ### }
195
+ ### })
196
+ ### .then(() => checkReadyToCompare());
197
+ ### }
198
 
199
  function updatePreview(blob, target) {
200
  const reader = new FileReader();