UI: player screen sender session_token til lie-submit #38
@@ -6,6 +6,7 @@
|
|||||||
<input id="nickname" placeholder="Nickname">
|
<input id="nickname" placeholder="Nickname">
|
||||||
<button onclick="joinSession()">1) Join</button>
|
<button onclick="joinSession()">1) Join</button>
|
||||||
<input id="playerId" placeholder="Player id">
|
<input id="playerId" placeholder="Player id">
|
||||||
|
<input id="sessionToken" placeholder="Session token" type="password" readonly>
|
||||||
<input id="roundQuestionId" placeholder="Round question id">
|
<input id="roundQuestionId" placeholder="Round question id">
|
||||||
<input id="lieText" placeholder="Din løgn">
|
<input id="lieText" placeholder="Din løgn">
|
||||||
<button onclick="submitLie()">2) Submit løgn</button>
|
<button onclick="submitLie()">2) Submit løgn</button>
|
||||||
@@ -17,10 +18,10 @@
|
|||||||
function code(){return document.getElementById("code").value.trim().toUpperCase();}
|
function code(){return document.getElementById("code").value.trim().toUpperCase();}
|
||||||
function pid(){return document.getElementById("playerId").value.trim();}
|
function pid(){return document.getElementById("playerId").value.trim();}
|
||||||
function rq(){return document.getElementById("roundQuestionId").value.trim();}
|
function rq(){return document.getElementById("roundQuestionId").value.trim();}
|
||||||
async function api(path,method,payload){var o={method:method||"GET",headers:{"Accept":"application/json"}};if(payload!==null){o.headers["Content-Type"]="application/json";o.body=JSON.stringify(payload);}var r=await fetch(path,o);var d=await r.json().catch(function(){return {};});document.getElementById("out").textContent=JSON.stringify({status:r.status,data:d},null,2);if(d.player&&d.player.id){document.getElementById("playerId").value=d.player.id;}if(d.round_question&&d.round_question.id){document.getElementById("roundQuestionId").value=d.round_question.id;}return d;}
|
async function api(path,method,payload){var o={method:method||"GET",headers:{"Accept":"application/json"}};if(payload!==null){o.headers["Content-Type"]="application/json";o.body=JSON.stringify(payload);}var r=await fetch(path,o);var d=await r.json().catch(function(){return {};});document.getElementById("out").textContent=JSON.stringify({status:r.status,data:d},null,2);if(d.player&&d.player.id){document.getElementById("playerId").value=d.player.id;}if(d.player&&d.player.session_token){document.getElementById("sessionToken").value=d.player.session_token;}if(d.round_question&&d.round_question.id){document.getElementById("roundQuestionId").value=d.round_question.id;}return d;}
|
||||||
function joinSession(){return api("/lobby/sessions/join","POST",{code:code(),nickname:document.getElementById("nickname").value.trim()});}
|
function joinSession(){return api("/lobby/sessions/join","POST",{code:code(),nickname:document.getElementById("nickname").value.trim()});}
|
||||||
function sessionDetail(){return api("/lobby/sessions/"+code(),"GET",null);}
|
function sessionDetail(){return api("/lobby/sessions/"+code(),"GET",null);}
|
||||||
function submitLie(){return api("/lobby/sessions/"+code()+"/questions/"+rq()+"/lies/submit","POST",{player_id:parseInt(pid(),10),text:document.getElementById("lieText").value});}
|
function submitLie(){return api("/lobby/sessions/"+code()+"/questions/"+rq()+"/lies/submit","POST",{player_id:parseInt(pid(),10),session_token:document.getElementById("sessionToken").value,text:document.getElementById("lieText").value});}
|
||||||
function submitGuess(){return api("/lobby/sessions/"+code()+"/questions/"+rq()+"/guesses/submit","POST",{player_id:parseInt(pid(),10),selected_text:document.getElementById("guessText").value});}
|
function submitGuess(){return api("/lobby/sessions/"+code()+"/questions/"+rq()+"/guesses/submit","POST",{player_id:parseInt(pid(),10),selected_text:document.getElementById("guessText").value});}
|
||||||
</script>
|
</script>
|
||||||
</body></html>
|
</body></html>
|
||||||
|
|||||||
@@ -751,6 +751,8 @@ class UiScreenTests(TestCase):
|
|||||||
response = self.client.get(reverse("lobby:player_screen"))
|
response = self.client.get(reverse("lobby:player_screen"))
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "Player panel")
|
self.assertContains(response, "Player panel")
|
||||||
|
self.assertContains(response, "id=\"sessionToken\"")
|
||||||
|
self.assertContains(response, "session_token")
|
||||||
|
|
||||||
|
|
||||||
class SessionDetailRoundQuestionTests(TestCase):
|
class SessionDetailRoundQuestionTests(TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user