BraydenMoore commited on
Commit
eb74bfc
1 Parent(s): 5f8dbff

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +46 -43
templates/index.html CHANGED
@@ -274,13 +274,6 @@
274
  const loadingGif = "{{ url_for('static', filename='eye.gif') }}";
275
  const newUrl = decodeURIComponent("{{ url|safe }}");
276
 
277
- feed.style.width = "80px";
278
- feed.style.height = "50px";
279
- feed.src = loadingGif;
280
- feed.style.opacity = "0.15";
281
- infoText.style.opacity = "0";
282
- locationName.textContent = "{{ page_title|safe }}";
283
-
284
  async function refreshImage() {
285
  try {
286
  const response = await fetch(newUrl, { method: 'HEAD' });
@@ -297,47 +290,57 @@
297
  }
298
  }
299
 
300
- feed.onload = function() {
301
- if (firstLoad) {
302
- countryElement.textContent = "connecting...";
303
- infoDiv.style.opacity = "0";
304
- }
305
- firstLoad = false;
 
306
 
307
- setTimeout(() => {
308
- locationName.textContent = "{{ name|safe }}";
309
- countryElement.textContent = "{{ country|safe }}";
310
- feed.style.width = "100%";
311
- feed.style.height = "70%";
312
- feed.style.opacity = "1";
313
- infoDiv.style.opacity = "1";
314
- }, 100);
315
 
316
- infoText.style.opacity = "1";
317
- setTimeout(refreshImage, 500);
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')) {
325
- firstLoad = false;
326
- feed.style.width = "80px";
327
- feed.style.height = "50px";
328
- feed.src = loadingGif;
329
- feed.style.opacity = "0.15";
330
- countryElement.textContent = "couldn't connect.";
331
- } else if (firstLoad) {
332
- window.location.href = "?new=true";
333
- } else {
334
- firstLoad = false;
335
- console.log("Trying again");
336
- setTimeout(refreshImage, 250);
337
- }
338
- };
 
 
 
 
 
 
 
 
339
 
340
- refreshImage();
341
  console.log('Feed load initiated');
342
  });
343
 
 
274
  const loadingGif = "{{ url_for('static', filename='eye.gif') }}";
275
  const newUrl = decodeURIComponent("{{ url|safe }}");
276
 
 
 
 
 
 
 
 
277
  async function refreshImage() {
278
  try {
279
  const response = await fetch(newUrl, { method: 'HEAD' });
 
290
  }
291
  }
292
 
293
+ async function init() {
294
+ feed.style.width = "80px";
295
+ feed.style.height = "50px";
296
+ feed.src = loadingGif;
297
+ feed.style.opacity = "0.15";
298
+ infoText.style.opacity = "0";
299
+ locationName.textContent = "{{ page_title|safe }}";
300
 
301
+ await refreshImage();
 
 
 
 
 
 
 
302
 
303
+ feed.onload = function() {
304
+ if (firstLoad) {
305
+ countryElement.textContent = "connecting...";
306
+ infoDiv.style.opacity = "0";
307
+ }
308
+ firstLoad = false;
309
 
310
+ setTimeout(() => {
311
+ locationName.textContent = "{{ name|safe }}";
312
+ countryElement.textContent = "{{ country|safe }}";
313
+ feed.style.width = "100%";
314
+ feed.style.height = "70%";
315
+ feed.style.opacity = "1";
316
+ infoDiv.style.opacity = "1";
317
+ }, 100);
318
 
319
+ infoText.style.opacity = "1";
320
+ };
321
+
322
+ feed.onerror = function() {
323
+ console.error('Error loading feed', this.src);
324
+ const urlParams = new URLSearchParams(window.location.search);
325
+
326
+ if (urlParams.get('id')) {
327
+ firstLoad = false;
328
+ feed.style.width = "80px";
329
+ feed.style.height = "50px";
330
+ feed.src = loadingGif;
331
+ feed.style.opacity = "0.15";
332
+ countryElement.textContent = "couldn't connect.";
333
+ } else if (firstLoad) {
334
+ window.location.href = "?new=true";
335
+ } else {
336
+ firstLoad = false;
337
+ console.log("Trying again");
338
+ setTimeout(refreshImage, 250);
339
+ }
340
+ };
341
+ }
342
 
343
+ init();
344
  console.log('Feed load initiated');
345
  });
346