BraydenMoore commited on
Commit
42f0942
1 Parent(s): 28b8289

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +13 -8
templates/index.html CHANGED
@@ -284,15 +284,20 @@
284
  async function refreshImage() {
285
  try {
286
  const response = await fetch(newUrl, { method: 'HEAD' });
287
- if (response.ok && /image\/jpe?g/.test(response.headers.get('Content-Type'))) {
288
- feed.src = newUrl;
 
 
 
 
 
289
  }
290
  } catch (error) {
291
  console.error('Fetch failed:', error);
292
  }
293
  }
294
 
295
- feed.onload = async function() {
296
  if (firstLoad) {
297
  countryElement.textContent = "connecting...";
298
  infoDiv.style.opacity = "0";
@@ -309,11 +314,11 @@
309
  }, 100);
310
 
311
  infoText.style.opacity = "1";
312
- await refreshImage();
313
  };
314
 
315
  feed.onerror = function() {
316
- console.error('Error loading image', this.src);
317
  const urlParams = new URLSearchParams(window.location.search);
318
 
319
  if (urlParams.get('id')) {
@@ -331,14 +336,14 @@
331
  setTimeout(refreshImage, 250);
332
  }
333
  };
334
-
335
- refreshImage();
336
- feed.src = newUrl;
337
  console.log('Feed load initiated');
338
  });
339
 
340
 
341
 
 
342
  // Time count
343
  document.addEventListener("DOMContentLoaded", function() {
344
  const timezone = "{{ timezone }}";
 
284
  async function refreshImage() {
285
  try {
286
  const response = await fetch(newUrl, { method: 'HEAD' });
287
+ const contentType = response.headers.get('Content-Type');
288
+ if (response.ok) {
289
+ if (/image\/jpe?g/.test(contentType)) {
290
+ feed.src = newUrl + '?t=' + new Date().getTime();
291
+ } else if (/video/.test(contentType)) {
292
+ feed.src = newUrl;
293
+ }
294
  }
295
  } catch (error) {
296
  console.error('Fetch failed:', error);
297
  }
298
  }
299
 
300
+ feed.onload = function() {
301
  if (firstLoad) {
302
  countryElement.textContent = "connecting...";
303
  infoDiv.style.opacity = "0";
 
314
  }, 100);
315
 
316
  infoText.style.opacity = "1";
317
+ setTimeout(refreshImage, 1000); // Refresh every second if it's an image
318
  };
319
 
320
  feed.onerror = function() {
321
+ console.error('Error loading feed', this.src);
322
  const urlParams = new URLSearchParams(window.location.search);
323
 
324
  if (urlParams.get('id')) {
 
336
  setTimeout(refreshImage, 250);
337
  }
338
  };
339
+
340
+ refreshImage(); // This will trigger feed.onload when the feed is loaded
 
341
  console.log('Feed load initiated');
342
  });
343
 
344
 
345
 
346
+
347
  // Time count
348
  document.addEventListener("DOMContentLoaded", function() {
349
  const timezone = "{{ timezone }}";