From b335707b7f446f346ada528f63870aa4d0a5aa09 Mon Sep 17 00:00:00 2001 From: Zutatensuppe Date: Sat, 1 May 2021 08:59:39 +0200 Subject: [PATCH] prepare for vue, make game run not in body, but in certain element --- public/game.js | 16 +++++++++------- templates/game.html.twig | 2 ++ templates/replay.html.twig | 2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/public/game.js b/public/game.js index 8809dc2..f598d19 100644 --- a/public/game.js +++ b/public/game.js @@ -17,6 +17,8 @@ if (typeof MODE === 'undefined') throw '[ MODE not set ]' if (typeof DEBUG === 'undefined') window.DEBUG = false +const TARGET_EL = document.getElementById('app') + const MODE_PLAY = 'play' const MODE_REPLAY = 'replay' @@ -27,7 +29,7 @@ let TIME = () => Time.timestamp() function addCanvasToDom(canvas) { canvas.width = window.innerWidth canvas.height = window.innerHeight - document.body.appendChild(canvas) + TARGET_EL.appendChild(canvas) window.addEventListener('resize', () => { canvas.width = window.innerWidth canvas.height = window.innerHeight @@ -306,12 +308,12 @@ function addMenuToDom(gameId) { scoresEl.appendChild(scoresTitleEl) scoresEl.appendChild(scoresListEl) - document.body.appendChild(settingsOverlay) - document.body.appendChild(previewOverlay) - document.body.appendChild(helpOverlay) - document.body.appendChild(timerEl) - document.body.appendChild(menuEl) - document.body.appendChild(scoresEl) + TARGET_EL.appendChild(settingsOverlay) + TARGET_EL.appendChild(previewOverlay) + TARGET_EL.appendChild(helpOverlay) + TARGET_EL.appendChild(timerEl) + TARGET_EL.appendChild(menuEl) + TARGET_EL.appendChild(scoresEl) return { bgColorPickerEl, diff --git a/templates/game.html.twig b/templates/game.html.twig index fad127d..1e948fd 100644 --- a/templates/game.html.twig +++ b/templates/game.html.twig @@ -1,6 +1,7 @@ +