Commit
·
9bcd4b9
1
Parent(s):
609ea1e
Update templates/index.html
Browse files- templates/index.html +15 -9
templates/index.html
CHANGED
|
@@ -283,20 +283,26 @@
|
|
| 283 |
locationName.textContent = "{{ page_title|safe }}";
|
| 284 |
|
| 285 |
const newUrl = "{{ url|safe }}";
|
| 286 |
-
|
|
|
|
|
|
|
| 287 |
function refreshImage() {
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
if (xhr.status === 200) {
|
| 293 |
if (xhr.getResponseHeader('Content-Type') === 'image/jpeg') {
|
| 294 |
img.src = newUrl + "?r=" + new Date().getTime();
|
|
|
|
|
|
|
| 295 |
}
|
| 296 |
}
|
| 297 |
-
}
|
| 298 |
-
|
| 299 |
-
|
|
|
|
|
|
|
| 300 |
}
|
| 301 |
|
| 302 |
const img = new Image();
|
|
|
|
| 283 |
locationName.textContent = "{{ page_title|safe }}";
|
| 284 |
|
| 285 |
const newUrl = "{{ url|safe }}";
|
| 286 |
+
|
| 287 |
+
let contentTypeChecked = false;
|
| 288 |
+
let isJpeg = false;
|
| 289 |
function refreshImage() {
|
| 290 |
+
if (!isJpeg && !contentTypeChecked) {
|
| 291 |
+
let xhr = new XMLHttpRequest();
|
| 292 |
+
xhr.open('HEAD', newUrl, true);
|
| 293 |
+
xhr.onreadystatechange = function() {
|
| 294 |
+
if (xhr.readyState === 4 && xhr.status === 200) {
|
| 295 |
if (xhr.getResponseHeader('Content-Type') === 'image/jpeg') {
|
| 296 |
img.src = newUrl + "?r=" + new Date().getTime();
|
| 297 |
+
isJpeg = true;
|
| 298 |
+
contentTypeChecked = true;
|
| 299 |
}
|
| 300 |
}
|
| 301 |
+
};
|
| 302 |
+
xhr.send();
|
| 303 |
+
} else if (isJpeg && contentTypeChecked) {
|
| 304 |
+
img.src = newUrl + "?r=" + new Date().getTime();
|
| 305 |
+
}
|
| 306 |
}
|
| 307 |
|
| 308 |
const img = new Image();
|