Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
iROCKBUNNY committed Oct 12, 2023
1 parent bab5a8f commit 9cf3e96
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions assets/js/n-back.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,36 @@ function generateBlock(level,
var unloadTime = loadTime + loadInterval;
if (level === 0) {
for (var i = 0; i < totalSize; i++) {
stimuli.push({
'stimulus': _.sample(stimuliPool),
'is_target': true,
'load_time': loadTime,
'unload_time': unloadTime,
'answer': null,
'correct': null,
'response_time': null,
'timestamp': {
'load': null,
'response': null
}
});
if (_.random(1, totalSize - i) <= targetSize) {
targetSize--;
stimuli.push({
'stimulus': 'X',
'is_target': true,
'load_time': loadTime,
'unload_time': unloadTime,
'answer': null,
'correct': null,
'response_time': null,
'timestamp': {
'load': null,
'response': null
}
});
} else {
stimuli.push({
'stimulus': _.sample(_.difference(stimuliPool, ['X'])),
'is_target': false,
'load_time': loadTime,
'unload_time': unloadTime,
'answer': null,
'correct': null,
'response_time': null,
'timestamp': {
'load': null,
'response': null
}
});
};
loadTime += interval;
unloadTime += interval;
};
Expand Down Expand Up @@ -384,7 +401,7 @@ function loadResults() {
).form('set value', 'results', JSON.stringify({
'rest_start_timestamp': restBlockStartTime,
'blocks': blocks
}));
}, null, 4));
$('#action-buttons').children().remove();
$('#action-buttons').append(
$('<div>').addClass('ui fluid large primary copy button').attr('data-clipboard-target', '#results').text('Copy to Clipboard')
Expand Down

0 comments on commit 9cf3e96

Please sign in to comment.