aiom
Version:
A Highly Flexible and Modular Framework for Behavioral Experiments
57 lines (51 loc) • 2.3 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Instruction</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.3.4/axios.min.js"></script>
<link rel="icon" type="image/png" href="./images/favicon.png"/>
<link rel="stylesheet" href="./css/style.css">
<script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.5/dist/js.cookie.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type = "text/javascript" src="./scripts/utils_consensus.js"></script>
</head>
<body>
<div class="container" style="display: flex; flex-direction: column; align-items: center;">
<h1>Waiting Room</h1>
<p>Thanks for participating, <span id="participant-id"></span>!</p>
<p><span id="number-update"></span> participants are ready, please be patient to wait for other participants to join...</p>
<button onclick="beginExperiment()" disabled>Begin</button>
</div>
<script>
const n_teammates = Cookies.get('n_teammates');
function beginExperiment() {window.location.href = 'experiment';}
// Get the participant name from the cookie and update the page
$(document).ready(function() {
let participantName = Cookies.get('pid');
participantName = participantName.substring(3); // Remove the first 3 characters
$('#participant-id').text(participantName);
});
function updateWaitingRoom() {
axios.get('api/check_waitingroom', {
headers: {
'team_id': Number(Cookies.get('team_id')),
},
})
.then(response => {
const numberOfPeople = response.data.count;
$('#number-update').text(`${numberOfPeople}/${n_teammates}`);
if (numberOfPeople >= n_teammates) {
$('button').prop('disabled', false);
}
})
.catch(function (error) {
console.error('Error fetching waiting room data:', error);
});
}
updateWaitingRoom();
setInterval(updateWaitingRoom, 500); // Update every 5 seconds
</script>
</body>
</html>