jsPsych/examples/jspsych-html-button-response.html
Josh de Leeuw e778028d0b Merge pull request #3298 from thtTNT/main
Add parameter "enable_button_after" to all "-button-response" plugins

(rebased-with-history from commit 87d2a8e0ab)
2024-06-07 22:49:07 +02:00

73 lines
2.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script src="../packages/jspsych/dist/index.browser.js"></script>
<script src="../packages/plugin-html-button-response/dist/index.browser.js"></script>
<link rel="stylesheet" href="../packages/jspsych/css/jspsych.css">
</head>
<body></body>
<script>
var jsPsych = initJsPsych({
on_finish: function() {
jsPsych.data.displayData();
}
});
var timeline = [];
timeline.push({
type: jsPsychHtmlButtonResponse,
stimulus: '<p style="color: red; font-size: 48px; font-weight: bold;">GREEN</p>',
choices: ['Green', 'Blue', 'Red'],
button_layout: "flex",
prompt: "<p>What color is this word? (flex layout)</p>"
});
timeline.push({
type: jsPsychHtmlButtonResponse,
stimulus: '<p style="color: red; font-size: 48px; font-weight: bold;">GREEN</p>',
choices: ['Green', 'Blue', 'Red'],
button_layout: "grid",
prompt: "<p>What color is this word? (grid layout)</p>"
});
timeline.push({
type: jsPsychHtmlButtonResponse,
stimulus: '<p style="color: red; font-size: 48px; font-weight: bold;">GREEN</p>',
choices: ['Green', 'Blue', 'Red'],
button_layout: "grid",
grid_rows: 2,
prompt: "<p>What color is this word? (grid layout, two rows)</p>"
});
timeline.push({
type: jsPsychHtmlButtonResponse,
stimulus: '<p style="color: green; font-size: 48px; font-weight: bold;">GREEN</p>',
choices: ['Green', 'Blue', 'Red'],
stimulus_duration: 1000,
prompt: "<p>What color is this word? (word disappears after 1s)</p>"
});
timeline.push({
type: jsPsychHtmlButtonResponse,
stimulus: '<p style="color: blue; font-size: 48px; font-weight: bold;">RED</p>',
choices: ['Green', 'Blue', 'Red'],
trial_duration: 2000,
response_ends_trial: false,
prompt: "<p>What color is this word? (trial ends after 2s)</p>"
});
timeline.push({
type: jsPsychHtmlButtonResponse,
stimulus: '<p style="color: red; font-size: 48px; font-weight: bold;">GREEN</p>',
choices: ['Green', 'Blue', 'Red'],
enable_button_after: 2000,
prompt: "<p>What color is this word? (button enable after 2s)</p>"
});
jsPsych.run(timeline);
</script>
</html>