From 01bec8bf90a26674550049f0f5b4758c801ad083 Mon Sep 17 00:00:00 2001 From: Elijah Steres Date: Wed, 30 Dec 2020 02:18:40 -0500 Subject: [PATCH] jquery load bad :( --- static/loader.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/static/loader.js b/static/loader.js index bb7190f..adf4e08 100644 --- a/static/loader.js +++ b/static/loader.js @@ -26,7 +26,6 @@ $(document).ready(function (){ for (var slotnum = 3; slotnum <= Math.min(maxslot, totalslots-1); slotnum++) { if (grid.children[slotnum].timestamp == timestamp) { - console.log(json[timestamp].update_text); updateGame(grid.children[slotnum], json[timestamp]); }; }; @@ -35,12 +34,14 @@ $(document).ready(function (){ const insertGame = (gridboxnum, gamestate, timestamp) => { var thisBox = grid.children[gridboxnum]; - thisBox.className = "game"; - thisBox.timestamp = timestamp; - thisBox.id = "loadTarget"; - $('#loadTarget').load("static/game.html"); - thisBox.id = ""; - updateGame(thisBox, gamestate); + fetch("/static/game.html").then(x=>x.text()).then(gamehtml => { + console.log(gamehtml) + console.log(thisBox) + thisBox.className = "game"; + thisBox.timestamp = timestamp; + thisBox.innerHTML = gamehtml; + updateGame(thisBox, gamestate); + }); }; const BASE_EMPTY = "/static/img/base_empty.png" @@ -59,7 +60,6 @@ $(document).ready(function (){ $('#updateTarget .home_score').html("" + gamestate.home_score); for (var i = 1; i <= 3; i++) { - $('#updateTarget .base_' + i).attr('src', (gamestate.bases[i] == null ? BASE_EMPTY : BASE_FILLED)); } @@ -70,7 +70,6 @@ $(document).ready(function (){ $('#updateTarget .pitcher_name').html(gamestate.pitcher); $('#updateTarget .batter_name').html(gamestate.batter); - console.log(gamestate.update_emoji); $('#updateTarget .update_emoji').html(gamestate.update_emoji); $('#updateTarget .update_text').html(gamestate.update_text);