33 lines
852 B
JavaScript
33 lines
852 B
JavaScript
import { initJsPsych } from "jspsych";
|
|
import "jspsych/css/jspsych.css";
|
|
import "./styles.css";
|
|
import { delayed_redirect } from "./utils/helpers.js";
|
|
import jsPsychHtmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
|
|
import { textStimuli } from './scripts/text_stimuli';
|
|
|
|
const debug = import.meta.env.VITE_DEBUG;
|
|
|
|
const jsPsych = initJsPsych({
|
|
on_finish: function() {
|
|
jsPsych.getDisplayElement().innerHTML = textStimuli.complete;
|
|
},
|
|
on_close: function() {
|
|
delayed_redirect(import.meta.env.VITE_CLOSED_URL);
|
|
},
|
|
on_data_update: function() {
|
|
if (debug) {
|
|
console.log(jsPsych.data.get().json());
|
|
}
|
|
},
|
|
});
|
|
|
|
const demo_trial = {
|
|
type: jsPsychHtmlKeyboardResponse,
|
|
stimulus: `<h1 class="text-2xl font-bold">Hello, world!</h1>`,
|
|
choices: [''],
|
|
};
|
|
|
|
const timeline = [demo_trial];
|
|
|
|
jsPsych.run(timeline);
|