Files
BPLabs/templates/eeg_mat_train_clinician_view.html

92 lines
3.2 KiB
HTML

{% extends 'index.html' %}
{% block content %}
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
<div class="card">
<div id="main-div" class="card-body">
<table id="eeg_test_table" class="table table-sm table">
<thead class="thead-dark">
<tr>
<th scope="col">Trial #</th>
<th scope="col">1</th>
<th scope="col">2</th>
<th scope="col">3</th>
<th scope="col">4</th>
</tr>
</thead>
<tbody>
<tr id="Q1">
<th scope="row">Q1</th>
<td class="T1">-</td>
<td class="T2">-</td>
<td class="T3">-</td>
<td class="T4">-</td>
</tr>
<tr id="Q2">
<th scope="row">Q2</th>
<td class="T1">-</td>
<td class="T2">-</td>
<td class="T3">-</td>
<td class="T4">-</td>
</tr>
</tbody>
</table>
<div>
<p id="q1"></p>
<p id="q2"></p>
</div>
<div class="d-flex justify-content-center mt-2" role="group">
<button type="button" id="eeg_test_save" class="btn btn-primary mx-3">Save test state</button>
<button type="button" id="eeg_test_finish" class="btn btn-primary mx-3">Finish test</button>
</div>
</div>
</div>
<script>
$(document).ready(function(){
// Initialise socketio with a namespace called "main"
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + '/main');
// Check if matrix stimulus is currently being processed
waitingDialog.show('Generating stimulus');
socket.on('eeg_test_fill_table', function(msg) {
for(i = 0; i < msg['data'].length; i++) {
for(j = 0; j < msg['data'][i].length; j++) {
$(`#Q${j+1} > .T${i+1}`).text(String.fromCharCode(msg['data'][i][j]));
}
}
});
socket.on('test_resp', function(msg) {
var t_ind = msg['trial_ind'];
var q_ind = msg['q_ind'];
$(`#Q${q_ind+1} > .T${t_ind+1}`).text(String.fromCharCode(msg['ans']));
});
socket.on('display_instructions', function(msg) {
$("#q1").text("Q1: "+msg['sentence_1'])
$("#q2").text("Q2: "+msg['sentence_2'])
});
socket.on('test_ready', function(msg) {
$("#q1").text("Q1: "+msg['sentence_1'])
$("#q2").text("Q2: "+msg['sentence_2'])
waitingDialog.hide();
});
$('#eeg_test_save').click(function(event) {
socket.emit("open_save_file_dialog")
});
$('#eeg_test_finish').click(function(event) {
socket.emit("finish_test")
});
// Catch message when asynchronous process is complete
socket.on('processing-complete', function(msg) {
alert("Matrix stimulus processing complete!")
window.location.href = '/eeg/train/mat/clinician/complete';
});
});
</script>
{% endblock %}