mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
add demo files
This commit is contained in:
parent
c55b41e3b1
commit
b014af592d
61
docs/demos/jspsych-sketchpad-demo1.html
Normal file
61
docs/demos/jspsych-sketchpad-demo1.html
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://unpkg.com/jspsych@7.0.0"></script>
|
||||||
|
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.0.0"></script>
|
||||||
|
<script src="https://unpkg.com/@jspsych/plugin-sketchpad@1.0.0"></script>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://unpkg.com/jspsych@7.0.0/css/jspsych.css"
|
||||||
|
/>
|
||||||
|
<style>
|
||||||
|
.jspsych-btn {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var jsPsych = initJsPsych();
|
||||||
|
|
||||||
|
var start = {
|
||||||
|
type: jsPsychHtmlButtonResponse,
|
||||||
|
stimulus: '',
|
||||||
|
choices: ['Run demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var show_data = {
|
||||||
|
type: jsPsychHtmlButtonResponse,
|
||||||
|
stimulus: function() {
|
||||||
|
var trial_data = jsPsych.data.getLastTrialData().values();
|
||||||
|
var trial_json = JSON.stringify(trial_data, null, 2);
|
||||||
|
return `<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>
|
||||||
|
<pre style="margin-top:0px;text-align:left;">${trial_json}</pre>`;
|
||||||
|
},
|
||||||
|
choices: ['Repeat demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var trial = {
|
||||||
|
type: jsPsychSketchpad,
|
||||||
|
prompt: '<p>Draw an apple!</p>',
|
||||||
|
prompt_location: 'abovecanvas',
|
||||||
|
canvas_width: 300,
|
||||||
|
canvas_height: 300,
|
||||||
|
border_width: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
var trial_loop = {
|
||||||
|
timeline: [trial, show_data],
|
||||||
|
loop_function: function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof jsPsych !== "undefined") {
|
||||||
|
jsPsych.run([start, trial_loop]);
|
||||||
|
} 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>
|
63
docs/demos/jspsych-sketchpad-demo2.html
Normal file
63
docs/demos/jspsych-sketchpad-demo2.html
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://unpkg.com/jspsych@7.0.0"></script>
|
||||||
|
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.0.0"></script>
|
||||||
|
<script src="https://unpkg.com/@jspsych/plugin-sketchpad@1.0.0"></script>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://unpkg.com/jspsych@7.0.0/css/jspsych.css"
|
||||||
|
/>
|
||||||
|
<style>
|
||||||
|
.jspsych-btn {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var jsPsych = initJsPsych();
|
||||||
|
|
||||||
|
var start = {
|
||||||
|
type: jsPsychHtmlButtonResponse,
|
||||||
|
stimulus: '',
|
||||||
|
choices: ['Run demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var show_data = {
|
||||||
|
type: jsPsychHtmlButtonResponse,
|
||||||
|
stimulus: function() {
|
||||||
|
var trial_data = jsPsych.data.getLastTrialData().values();
|
||||||
|
var trial_json = JSON.stringify(trial_data, null, 2);
|
||||||
|
return `<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>
|
||||||
|
<pre style="margin-top:0px;text-align:left;">${trial_json}</pre>`;
|
||||||
|
},
|
||||||
|
choices: ['Repeat demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var trial = {
|
||||||
|
type: jsPsychSketchpad,
|
||||||
|
prompt: '<p>Circle the mouth using red. Circle the eyes using blue.</p>',
|
||||||
|
prompt_location: 'abovecanvas',
|
||||||
|
stroke_color_palette: ['red', 'blue'],
|
||||||
|
stroke_color: 'red',
|
||||||
|
background_image: 'img/sad_face_4.jpg',
|
||||||
|
canvas_width: 380,
|
||||||
|
canvas_height: 252
|
||||||
|
}
|
||||||
|
|
||||||
|
var trial_loop = {
|
||||||
|
timeline: [trial, show_data],
|
||||||
|
loop_function: function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof jsPsych !== "undefined") {
|
||||||
|
jsPsych.run([start, trial_loop]);
|
||||||
|
} 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>
|
@ -64,58 +64,46 @@ In addition to the [default data collected by all plugins](../overview/plugins.m
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
???+ example "Identical distractors"
|
???+ example "Basic sketchpad with a prompt"
|
||||||
=== "Code"
|
=== "Code"
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var instructions = {
|
|
||||||
type: jsPsychHtmlButtonResponse,
|
|
||||||
stimulus: `<p>Press J if there is a backwards N.</p>
|
|
||||||
<p>Press F if all the Ns are in the normal orientation.</p>`,
|
|
||||||
choices: ['Continue']
|
|
||||||
}
|
|
||||||
|
|
||||||
var trial = {
|
var trial = {
|
||||||
type: jsPsychVisualSearchCircle,
|
type: jsPsychSketchpad,
|
||||||
target: 'img/backwardN.gif',
|
prompt: '<p>Draw an apple!</p>',
|
||||||
foil: 'img/normalN.gif',
|
prompt_location: 'abovecanvas',
|
||||||
fixation_image: 'img/fixation.gif',
|
canvas_width: 300,
|
||||||
target_present: true,
|
canvas_height: 300,
|
||||||
set_size: 4
|
border_width: 2
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Demo"
|
=== "Demo"
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
<iframe src="../../demos/jspsych-visual-search-circle-demo1.html" width="90%;" height="500px;" frameBorder="0"></iframe>
|
<iframe src="../../demos/jspsych-sketchpad-demo1.html" width="90%;" height="500px;" frameBorder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a target="_blank" rel="noopener noreferrer" href="../../demos/jspsych-visual-search-circle-demo1.html">Open demo in new tab</a>
|
<a target="_blank" rel="noopener noreferrer" href="../../demos/jspsych-sketchpad-demo1.html">Open demo in new tab</a>
|
||||||
|
|
||||||
???+ example "Variety of different distractors"
|
???+ example "Image segmentation with different colors"
|
||||||
=== "Code"
|
=== "Code"
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var instructions = {
|
|
||||||
type: jsPsychHtmlButtonResponse,
|
|
||||||
stimulus: `<p>Press E if there is an elephant in the group.</p>
|
|
||||||
<p>Press N if there is no elephant in the group.</p>`,
|
|
||||||
choices: ['Continue']
|
|
||||||
}
|
|
||||||
|
|
||||||
var trial = {
|
var trial = {
|
||||||
type: jsPsychVisualSearchCircle,
|
type: jsPsychSketchpad,
|
||||||
stimuli: ['img/elephant.png', 'img/lion.png', 'img/monkey.png'],
|
prompt: '<p style="width:380px">Circle the mouth using red. Circle the eyes using blue.</p>',
|
||||||
fixation_image: 'img/fixation.gif',
|
prompt_location: 'abovecanvas',
|
||||||
target_present_key: 'e',
|
stroke_color_palette: ['red', 'blue'],
|
||||||
target_absent_key: 'n',
|
stroke_color: 'red',
|
||||||
target_present: true
|
background_image: 'img/sad_face_4.jpg',
|
||||||
|
canvas_width: 380,
|
||||||
|
canvas_height: 252
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Demo"
|
=== "Demo"
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
<iframe src="../../demos/jspsych-visual-search-circle-demo2.html" width="90%;" height="500px;" frameBorder="0"></iframe>
|
<iframe src="../../demos/jspsych-sketchpad-demo2.html" width="90%;" height="500px;" frameBorder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a target="_blank" rel="noopener noreferrer" href="../../demos/jspsych-visual-search-circle-demo2.html">Open demo in new tab</a>
|
<a target="_blank" rel="noopener noreferrer" href="../../demos/jspsych-sketchpad-demo2.html">Open demo in new tab</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user