|
99 | 99 | let mouseDown = false;
|
100 | 100 | let clickX;
|
101 | 101 | let clickY;
|
| 102 | + let imageUrl; |
102 | 103 | let previousImageUrl;
|
103 | 104 | let frameLoadStartTime;
|
104 | 105 | const imgElement = document.getElementById("img");
|
|
152 | 153 | }
|
153 | 154 |
|
154 | 155 | function playPause() {
|
155 |
| - currentIndex = parseInt(currentIndexInput.value); |
156 | 156 | if (!playbackStopped) {
|
157 | 157 | playbackStopped = true;
|
158 | 158 | } else {
|
| 159 | + clearLog(); |
159 | 160 | playbackStopped = false;
|
| 161 | + loadFormData(); |
160 | 162 | changeFrame();
|
161 | 163 | }
|
162 | 164 | }
|
163 | 165 |
|
164 | 166 | function changeFrame() {
|
165 | 167 | frameLoadStartTime = Date.now();
|
166 | 168 | currentIndex += indexLeap;
|
167 |
| - const imageUrl = getImageUrl(); |
168 |
| - previousImageUrl = imgElement.getAttribute("src"); |
| 169 | + previousImageUrl = imageUrl; |
| 170 | + imageUrl = getImageUrl(); |
169 | 171 | console.log(imageUrl);
|
170 | 172 | imgElement.setAttribute("src", imageUrl);
|
171 | 173 | currentIndexInput.value = currentIndex;
|
|
193 | 195 |
|
194 | 196 | imgElement.onerror = function() {
|
195 | 197 | if (!playbackStopped) {
|
196 |
| - log("error loading image at " + imgElement.getAttribute("src")); |
| 198 | + log("error loading image at " + imageUrl); |
197 | 199 | playbackStopped = true;
|
198 |
| - imgElement.setAttribute("src", previousImageUrl); |
| 200 | + imageUrl = previousImageUrl; |
| 201 | + imgElement.setAttribute("src", imageUrl); |
199 | 202 | }
|
200 | 203 | }
|
201 | 204 |
|
202 | 205 | firstImageInput.onchange = function() {
|
203 | 206 | const imageName = this.files[0].name;
|
204 | 207 | const match = /\d+(?!.*\d)/g.exec(imageName);
|
205 | 208 | if (match === null) {
|
206 |
| - alert("File doesn't have a numeric index in it's name.") |
| 209 | + alert("The selected image file doesn't have a numeric index in its name.") |
207 | 210 | } else {
|
208 | 211 | const firstIndex = match[0];
|
209 | 212 | const prefix = imageName.substring(0, match.index);
|
|
214 | 217 | currentIndexInput.value = firstIndex;
|
215 | 218 | loadFormData();
|
216 | 219 | if (path) {
|
217 |
| - imgElement.setAttribute("src", getImageUrl()); |
| 220 | + previousImageUrl = imageUrl; |
| 221 | + imageUrl = getImageUrl(); |
| 222 | + imgElement.setAttribute("src", imageUrl); |
218 | 223 | }
|
219 | 224 | }
|
220 | 225 | };
|
|
224 | 229 | if (path) {
|
225 | 230 | path = "file:///" + path;
|
226 | 231 | }
|
| 232 | + previousImageUrl = imageUrl; |
227 | 233 | if (path && currentIndex !== null) {
|
228 |
| - imgElement.setAttribute("src", getImageUrl()); |
| 234 | + imageUrl = getImageUrl(); |
229 | 235 | } else {
|
230 |
| - imgElement.setAttribute("src", ""); |
| 236 | + imageUrl = ""; |
231 | 237 | }
|
| 238 | + imgElement.setAttribute("src", imageUrl); |
232 | 239 | };
|
233 | 240 |
|
234 | 241 | flipUpsideDownInput.onchange = function() {
|
|
278 | 285 | switch (key) {
|
279 | 286 | case 37: //left
|
280 | 287 | currentIndex -= parseInt(indexLeapInput.value);
|
281 |
| - imgElement.setAttribute("src", getImageUrl()); |
| 288 | + previousImageUrl = imageUrl; |
| 289 | + imageUrl = getImageUrl(); |
| 290 | + imgElement.setAttribute("src", imageUrl); |
282 | 291 | currentIndexInput.value = currentIndex;
|
283 | 292 | break;
|
284 |
| - case 39://right |
| 293 | + case 39: //right |
285 | 294 | currentIndex += parseInt(indexLeapInput.value);
|
286 |
| - imgElement.setAttribute("src", getImageUrl()); |
| 295 | + previousImageUrl = imageUrl; |
| 296 | + imageUrl = getImageUrl(); |
| 297 | + imgElement.setAttribute("src", imageUrl); |
287 | 298 | currentIndexInput.value = currentIndex;
|
288 | 299 | break;
|
289 | 300 | }
|
|
293 | 304 | //init
|
294 | 305 | loadFormData();
|
295 | 306 | if (path && currentIndex !== null) {
|
296 |
| - imgElement.setAttribute("src", getImageUrl()); |
| 307 | + imageUrl = getImageUrl(); |
| 308 | + imgElement.setAttribute("src", imageUrl); |
297 | 309 | }
|
298 | 310 |
|
299 | 311 | </script>
|
|
0 commit comments