BraydenMoore commited on
Commit
aa3be44
·
1 Parent(s): cf8f5f9

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +6 -7
templates/index.html CHANGED
@@ -266,7 +266,7 @@
266
  <script>
267
 
268
  // init
269
- document.addEventListener("DOMContentLoaded", () => {
270
  const feed = document.getElementById("feed");
271
  const infoText = document.getElementById("info-text");
272
  const country = document.getElementById("country");
@@ -281,22 +281,21 @@
281
  infoText.style.opacity = "0";
282
  };
283
 
284
- const setLoadedState = (url) => {
285
- feed.src = url;
286
  feed.style.width = "100%";
287
  feed.style.height = "70%";
288
  feed.style.opacity = "1";
289
  infoText.style.opacity = "1";
290
  country.textContent = "{{ country }}";
291
  };
292
-
293
  const refreshImage = () => {
294
  let xhr = new XMLHttpRequest();
295
- const urlWithTimestamp = `${newUrl}?t=${new Date().getTime()}`;
296
- xhr.open('HEAD', urlWithTimestamp, true);
297
  xhr.onreadystatechange = () => {
298
  if (xhr.readyState === 4 && xhr.status === 200 && xhr.getResponseHeader('Content-Type') === 'image/jpeg') {
299
- setLoadedState(urlWithTimestamp);
300
  }
301
  };
302
  xhr.send();
 
266
  <script>
267
 
268
  // init
269
+ document.addEventListener("DOMContentLoaded", () => {
270
  const feed = document.getElementById("feed");
271
  const infoText = document.getElementById("info-text");
272
  const country = document.getElementById("country");
 
281
  infoText.style.opacity = "0";
282
  };
283
 
284
+ const setLoadedState = () => {
285
+ feed.src = `${newUrl}?t=${new Date().getTime()}`;
286
  feed.style.width = "100%";
287
  feed.style.height = "70%";
288
  feed.style.opacity = "1";
289
  infoText.style.opacity = "1";
290
  country.textContent = "{{ country }}";
291
  };
292
+
293
  const refreshImage = () => {
294
  let xhr = new XMLHttpRequest();
295
+ xhr.open('HEAD', `${newUrl}?t=${new Date().getTime()}`, true);
 
296
  xhr.onreadystatechange = () => {
297
  if (xhr.readyState === 4 && xhr.status === 200 && xhr.getResponseHeader('Content-Type') === 'image/jpeg') {
298
+ setLoadedState();
299
  }
300
  };
301
  xhr.send();