mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
88 lines
2.3 KiB
HTML
88 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<script src="../jspsych.js"></script>
|
|
<script src="../plugins/jspsych-html-keyboard-response.js"></script>
|
|
<script src="../plugins/jspsych-webgazer-calibrate.js"></script>
|
|
<script src="../plugins/jspsych-webgazer-validate.js"></script>
|
|
<script src="js/webgazer.js"></script>
|
|
<script src="../extensions/jspsych-ext-webgazer.js"></script>
|
|
<link rel="stylesheet" href="../css/jspsych.css">
|
|
<style>
|
|
.jspsych-content { max-width: 100%;}
|
|
</style>
|
|
</head>
|
|
|
|
<body></body>
|
|
|
|
<script>
|
|
|
|
var calibration = {
|
|
type: 'webgazer-calibrate',
|
|
calibration_points: [[50,50], [25,25], [25,75], [75,25], [75,75]],
|
|
repetitions_per_point: 1,
|
|
randomize_calibration_order: true,
|
|
time_per_point: 1000,
|
|
time_to_saccade: 1000
|
|
}
|
|
|
|
var validation = {
|
|
type: 'webgazer-validate',
|
|
validation_points: [[25,25], [25,75], [75,25], [75,75]]
|
|
}
|
|
|
|
var fixation = {
|
|
type: 'html-keyboard-response',
|
|
stimulus: '+',
|
|
choices: jsPsych.NO_KEYS,
|
|
trial_duration: 500
|
|
}
|
|
|
|
var trial = {
|
|
type: 'html-keyboard-response',
|
|
stimulus: function () {
|
|
return(
|
|
`<div style="position: relative; width: 50vh; height: 50vh;">
|
|
<div style="position: absolute; top:${jsPsych.timelineVariable('top', true)}%; left: ${jsPsych.timelineVariable('left', true)}%">
|
|
<span style="font-family: monospace; font-size: 40px;">${jsPsych.timelineVariable('direction', true) == 'left' ? '<' : '>'}</span>
|
|
</div>
|
|
</div>`
|
|
)
|
|
},
|
|
choices: ['a', 'l'],
|
|
post_trial_gap: 250,
|
|
extensions: ['webgazer']
|
|
}
|
|
|
|
var params = [
|
|
{ left: 0, top: 0, direction: 'left' },
|
|
{ left: 100, top: 0, direction: 'left' },
|
|
{ left: 0, top: 100, direction: 'left' },
|
|
{ left: 100, top: 100, direction: 'left' },
|
|
{ left: 0, top: 0, direction: 'right' },
|
|
{ left: 100, top: 0, direction: 'right' },
|
|
{ left: 0, top: 100, direction: 'right' },
|
|
{ left: 100, top: 100, direction: 'right' },
|
|
]
|
|
|
|
var trial_proc = {
|
|
timeline: [fixation, trial],
|
|
timeline_variables: params,
|
|
randomize_order: true
|
|
}
|
|
|
|
var timeline = [];
|
|
timeline.push(calibration);
|
|
timeline.push(validation);
|
|
timeline.push(trial_proc);
|
|
|
|
jsPsych.init({
|
|
timeline: timeline,
|
|
extensions: [
|
|
{type: 'webgazer'}
|
|
]
|
|
})
|
|
</script>
|
|
|
|
</html> |