mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
52 lines
1.6 KiB
HTML
52 lines
1.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="docs-demo-timeline.js"></script>
|
|
<script src="https://unpkg.com/jspsych@7.3.3"></script>
|
|
<script src="https://unpkg.com/@jspsych/plugin-canvas-slider-response@1.1.2"></script>
|
|
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.1.2"></script>
|
|
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.3.3/css/jspsych.css" />
|
|
<link rel="stylesheet" href="docs-demo.css" type="text/css" />
|
|
</head>
|
|
<body></body>
|
|
<script>
|
|
|
|
const jsPsych = initJsPsych();
|
|
|
|
// Draw two squares with additional parameters
|
|
|
|
let colors;
|
|
|
|
function twoSquares(c, colors) {
|
|
const ctx = c.getContext('2d');
|
|
ctx.fillStyle = colors[0];
|
|
ctx.fillRect(200, 70, 40, 40);
|
|
ctx.fillStyle = colors[1];
|
|
ctx.fillRect(260, 70, 40, 40);
|
|
}
|
|
|
|
const trial = {
|
|
type: jsPsychCanvasSliderResponse,
|
|
stimulus: function(c) {
|
|
colors = ['darkred', 'cyan'];
|
|
twoSquares(c, colors);
|
|
},
|
|
labels: ['Exactly<br>the same','Totally<br>different'],
|
|
canvas_size: [200, 500],
|
|
prompt: '<p>How different would you say the colors of these two squares are?</p>',
|
|
on_finish: function(data) {
|
|
data.color1 = colors[0];
|
|
data.color2 = colors[1];
|
|
}
|
|
};
|
|
|
|
const timeline = [trial];
|
|
|
|
if (typeof jsPsych !== "undefined") {
|
|
jsPsych.run(generateDocsDemoTimeline(timeline));
|
|
} else {
|
|
document.body.innerHTML = '<div style="text-align:center; margin-top:50%; transform:translate(0,-50%);">You must be online to view the plugin demo.</div>';
|
|
}
|
|
</script>
|
|
</html>
|