diff --git a/lobby/templates/lobby/host_screen.html b/lobby/templates/lobby/host_screen.html index d2a733d..5f0d17a 100644 --- a/lobby/templates/lobby/host_screen.html +++ b/lobby/templates/lobby/host_screen.html @@ -9,6 +9,7 @@

Kræver mindst 3 spillere i lobbyen.

Spillere i session: ukendt

+

Fase: ukendt (opdatér session-status).

@@ -25,6 +26,7 @@ var currentSessionStatus=""; function csrf(){var m=document.cookie.match(/csrftoken=([^;]+)/);return m?m[1]:"";} function code(){return document.getElementById("code").value.trim().toUpperCase();} function rq(){return document.getElementById("roundQuestionId").value.trim();} + function saveHostContext(){try{localStorage.setItem("wppHostContext",JSON.stringify({code:code(),round_question_id:rq(),session_status:currentSessionStatus||""}));}catch(_e){}} function restoreHostContext(){try{var raw=localStorage.getItem("wppHostContext");if(!raw){return false;}var ctx=JSON.parse(raw);if(ctx.code){document.getElementById("code").value=(ctx.code||"").toUpperCase();}if(ctx.round_question_id){document.getElementById("roundQuestionId").value=ctx.round_question_id;}if(ctx.session_status){currentSessionStatus=ctx.session_status;}return !!ctx.code;}catch(_e){return false;}} function phaseLabel(status){if(status==="lobby"){return"Lobby";}if(status==="lie"){return"Løgn";}if(status==="guess"){return"Gæt";}if(status==="reveal"){return"Reveal";}if(status==="finished"){return"Afsluttet";}return"Ukendt";} @@ -42,6 +44,7 @@ function showScoreboard(){return api("/lobby/sessions/"+code()+"/scoreboard","GE function nextRound(){return api("/lobby/sessions/"+code()+"/rounds/next","POST",{});} function finishGame(){return api("/lobby/sessions/"+code()+"/finish","POST",{});} ["code","roundQuestionId"].forEach(function(fieldId){var field=document.getElementById(fieldId);if(!field){return;}field.addEventListener("input",function(){syncStartRoundGuard(null);updateHostActionState();saveHostContext();});field.addEventListener("change",function(){syncStartRoundGuard(null);updateHostActionState();saveHostContext();});}); + updatePhaseStatus();syncStartRoundGuard(null);updateHostActionState(); if(restoreHostContext()){updatePhaseStatus();sessionDetail();}else{saveHostContext();} diff --git a/lobby/tests.py b/lobby/tests.py index cadcbd4..34c7d59 100644 --- a/lobby/tests.py +++ b/lobby/tests.py @@ -778,6 +778,7 @@ class UiScreenTests(TestCase): self.assertContains(response, "id=\"showQuestionBtn\"") self.assertContains(response, "id=\"mixAnswersBtn\"") self.assertContains(response, "id=\"hostActionHint\"") + self.assertContains(response, "id=\"phaseStatus\"") self.assertContains(response, "updateHostActionState") self.assertContains(response, "phaseLabel")