From a7a428357d2116000cf96121153af9187a2e08b4 Mon Sep 17 00:00:00 2001 From: SIMAILA Djalim Date: Sat, 14 Jan 2023 14:57:58 +0100 Subject: [PATCH] show and hide introduction view --- truthseeker/static/js/game.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/truthseeker/static/js/game.js b/truthseeker/static/js/game.js index 611bae2..f152989 100644 --- a/truthseeker/static/js/game.js +++ b/truthseeker/static/js/game.js @@ -16,18 +16,32 @@ function hideEmotionAndCulpritChoices(){ document.getElementsByClassName("emotion_and_culprit_choices")[0].classList.add("hidden"); } +function showIntroduction(){ + document.getElementsByClassName("introduction")[0].classList.remove("hidden"); +} +function hideIntroduction(){ + document.getElementsByClassName("introduction")[0].classList.add("hidden"); +} +function setListenerToIntroductionNextBtn(){ + document.getElementById("introduction_next_btn").addEventListener("click", showInterogation) +} + function setListenerToInterrogationNextBtn(){ - document.getElementById("interrogation_next_btn").addEventListener("click", showInterogationView) + document.getElementById("interrogation_next_btn").addEventListener("click", showEmotionAndCulpritChoicesView) } function showInterogationView(){ + hideIntroduction(); + showInterogation(); +} + +function showEmotionAndCulpritChoicesView(){ hideInterogation(); showEmotionAndCulpritChoices(); } function renderAnswerSelectionPanel() { npcs_ids.forEach(element => { - console.log(element); let suspect = document.createElement("div"); suspect.classList.add("suspect"); @@ -98,8 +112,8 @@ async function initGame(){ //initSock(); renderAnswerSelectionPanel(); renderInterogation(); + setListenerToIntroductionNextBtn() setListenerToInterrogationNextBtn(); - showInterogation(); + showIntroduction(); } - initGame(); \ No newline at end of file