Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse filescliquer sur "retour vers le futur" provoque l'affichage de "rose"
changement complet de la fonction selectPreset
- templates/index.html +46 -19
templates/index.html
CHANGED
@@ -149,25 +149,52 @@
|
|
149 |
}
|
150 |
}
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
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();
|