mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-22 22:38:24 +02:00
Add debug feature for problem draw, useful for final tournament
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -40,6 +40,20 @@ function drawDice(tid, trigram = null, result = null) {
|
||||
socket.send(JSON.stringify({'tid': tid, 'type': 'dice', 'trigram': trigram, 'result': result}))
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the requested dice from the buttons and request to draw it.
|
||||
* Only available for debug purposes and for admins.
|
||||
* @param tid The tournament id
|
||||
*/
|
||||
function drawDebugDice(tid) {
|
||||
let dice_10 = parseInt(document.querySelector(`input[name="debug-dice-${tid}-10"]:checked`).value)
|
||||
let dice_1 = parseInt(document.querySelector(`input[name="debug-dice-${tid}-1"]:checked`).value)
|
||||
let result = (dice_10 + dice_1) || 100
|
||||
let team_div = document.querySelector(`div[id="dices-${tid}"] > div > div[class*="text-bg-warning"]`)
|
||||
let team = team_div.getAttribute("data-team")
|
||||
drawDice(tid, team, result)
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to draw a new problem.
|
||||
* @param tid The tournament id
|
||||
@ -203,6 +217,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
elem.classList.add('text-bg-success')
|
||||
elem.innerText = `${trigram} 🎲 ${result}`
|
||||
}
|
||||
|
||||
let nextTeam = document.querySelector(` div[id="dices-${tid}"] > div > div[class*="text-bg-warning"]`).getAttribute("data-team")
|
||||
if (nextTeam) {
|
||||
// If there is one team that does not have launched its dice, then we update the debug section
|
||||
let debugSpan = document.getElementById(`debug-dice-${tid}-team`)
|
||||
if (debugSpan)
|
||||
debugSpan.innerText = nextTeam
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,10 +234,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
*/
|
||||
function updateDiceVisibility(tid, visible) {
|
||||
let div = document.getElementById(`launch-dice-${tid}`)
|
||||
if (visible)
|
||||
let div_debug = document.getElementById(`debug-dice-form-${tid}`)
|
||||
if (visible) {
|
||||
div.classList.remove('d-none')
|
||||
else
|
||||
div_debug.classList.remove('d-none')
|
||||
}
|
||||
else {
|
||||
div.classList.add('d-none')
|
||||
div_debug.classList.add('d-none')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -225,10 +252,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
*/
|
||||
function updateBoxVisibility(tid, visible) {
|
||||
let div = document.getElementById(`draw-problem-${tid}`)
|
||||
if (visible)
|
||||
let div_debug = document.getElementById(`debug-problem-form-${tid}`)
|
||||
if (visible) {
|
||||
div.classList.remove('d-none')
|
||||
else
|
||||
div_debug.classList.remove('d-none')
|
||||
}
|
||||
else {
|
||||
div.classList.add('d-none')
|
||||
div_debug.classList.add('d-none')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -582,6 +614,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
let teamLi = document.getElementById(`recap-${tid}-round-${round}-team-${team}`)
|
||||
if (teamLi !== null)
|
||||
teamLi.classList.add('list-group-item-info')
|
||||
|
||||
let debugSpan = document.getElementById(`debug-problem-${tid}-team`)
|
||||
if (debugSpan && team) {
|
||||
debugSpan.innerText = team
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user