mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00

The `run()` method takes a timeline and returns a promise that is resolved when the experiment finishes. Hence, jsPsych can now be initialized without starting an experiment. This re-enables usage of `jsPsych.timelineVariable()` in timeline definitions and repairs exclusion checks and extension loading.
45 lines
1.1 KiB
HTML
45 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../../dist/index.browser.js"></script>
|
|
<script src="../../../plugin-html-keyboard-response/dist/index.browser.js"></script>
|
|
<script src="calibration-timeline.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="../../css/jspsych.css" />
|
|
<style>
|
|
html,
|
|
body {
|
|
background: black;
|
|
color: white;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body></body>
|
|
<script>
|
|
var jsPsych = initJsPsych();
|
|
|
|
var start_calibration = {
|
|
type: jsPsychHtmlKeyboardResponse,
|
|
stimulus: 'Press any key to start calibration. Press spacebar when calibration is complete.'
|
|
}
|
|
|
|
var start = {
|
|
type: jsPsychHtmlKeyboardResponse,
|
|
stimulus: 'Press any key to start the test.'
|
|
}
|
|
|
|
var trial = {
|
|
type: jsPsychHtmlKeyboardResponse,
|
|
stimulus: `<div style="width:200px; height: 200px; background: white;"></div>`,
|
|
trial_duration: 500,
|
|
post_trial_gap: 250
|
|
}
|
|
|
|
var loop = {
|
|
timeline: [trial],
|
|
repetitions: 10
|
|
}
|
|
|
|
jsPsych.run([start_calibration, calibration, start, loop]);
|
|
</script>
|
|
</html>
|