diff --git a/docs/demos/docs-demo-timeline.js b/docs/demos/docs-demo-timeline.js new file mode 100644 index 00000000..d621ca13 --- /dev/null +++ b/docs/demos/docs-demo-timeline.js @@ -0,0 +1,52 @@ +function generateDocsDemoTimeline(timeline, setup_timeline) { + let setup; + if (setup_timeline) { + setup = { + timeline: setup_timeline, + }; + } + + const start = { + type: jsPsychHtmlButtonResponse, + stimulus: "", + choices: ["Run demo"], + }; + + let run = 0; + + let trial = { + timeline: timeline, + data: { + run: () => { + return run; + }, + }, + }; + + const show_data = { + type: jsPsychHtmlButtonResponse, + stimulus: ` +
Trial data:
+ `, + on_load: function () { + const trial_data = jsPsych.data.get().filter({ run: run }).ignore("run").values(); + const trial_json = JSON.stringify(trial_data, null, 2); + jsPsych.getDisplayElement().querySelector("pre").innerText = trial_json; + }, + choices: ["Repeat demo"], + }; + + const trial_loop = { + timeline: [trial, show_data], + loop_function: function () { + run++; + return true; + }, + }; + + if (setup_timeline) { + return [setup, start, trial_loop]; + } else { + return [start, trial_loop]; + } +} diff --git a/docs/demos/docs-demo.css b/docs/demos/docs-demo.css new file mode 100644 index 00000000..742a9fe9 --- /dev/null +++ b/docs/demos/docs-demo.css @@ -0,0 +1 @@ +.jspsych-btn {margin-bottom: 10px;} \ No newline at end of file diff --git a/docs/demos/eye-tracking-with-webgazer.html b/docs/demos/eye-tracking-with-webgazer.html index 5acbce96..ac61db76 100644 --- a/docs/demos/eye-tracking-with-webgazer.html +++ b/docs/demos/eye-tracking-with-webgazer.html @@ -15,11 +15,7 @@ rel="stylesheet" href="https://unpkg.com/jspsych@7.0.0/css/jspsych.css" /> - + - - - - - - - - + + + + + + + + + + const timeline = [animation_trial]; + if (typeof jsPsych !== "undefined") { + jsPsych.run(generateDocsDemoTimeline(timeline, [preload_trial])); + } else { + document.body.innerHTML = '