mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +00:00
Merge pull request #2111 from kurokida/docs-demos
Create live demos for the IAT and image-button/keyboard/slider plugins.
This commit is contained in:
commit
b283f69bad
66
docs/plugins/demos/jspsych-iat-html-demo1.html
Normal file
66
docs/plugins/demos/jspsych-iat-html-demo1.html
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/jspsych.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-preload.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-html-button-response.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-iat-html.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/css/jspsych.css">
|
||||||
|
<style>
|
||||||
|
.jspsych-btn {margin-bottom: 10px;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var start = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
stimulus: '',
|
||||||
|
choices: ['Run demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var show_data = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
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: 'iat-html',
|
||||||
|
stimulus: 'Golf',
|
||||||
|
stim_key_association: 'left',
|
||||||
|
html_when_wrong: '<span style="color: red; font-size: 80px">X</span>',
|
||||||
|
bottom_instructions: '<p>If you press the wrong key, a red X will appear. Press the other key to continue</p>',
|
||||||
|
force_correct_key_press: true,
|
||||||
|
display_feedback: true,
|
||||||
|
trial_duration: 3000, //Only if display_feedback is false
|
||||||
|
left_category_key: 'e',
|
||||||
|
right_category_key: 'i',
|
||||||
|
left_category_label: ['OLD'],
|
||||||
|
right_category_label: ['YOUNG'],
|
||||||
|
response_ends_trial: true
|
||||||
|
}
|
||||||
|
|
||||||
|
var trial_loop = {
|
||||||
|
timeline: [trial, show_data],
|
||||||
|
loop_function: function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof jsPsych !== "undefined") {
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [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>
|
72
docs/plugins/demos/jspsych-iat-image-demo1.html
Normal file
72
docs/plugins/demos/jspsych-iat-image-demo1.html
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/jspsych.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-preload.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-html-button-response.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-iat-image.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/css/jspsych.css">
|
||||||
|
<style>
|
||||||
|
.jspsych-btn {margin-bottom: 10px;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var preload_trial = {
|
||||||
|
type: 'preload',
|
||||||
|
auto_preload: true
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
stimulus: '',
|
||||||
|
choices: ['Run demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var show_data = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
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: 'iat-image',
|
||||||
|
stimulus: 'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/blue.png',
|
||||||
|
stim_key_association: 'left',
|
||||||
|
html_when_wrong: '<span style="color: red; font-size: 80px">X</span>',
|
||||||
|
bottom_instructions: '<p>If you press the wrong key, a red X will appear. Press the other key to continue</p>',
|
||||||
|
force_correct_key_press: true,
|
||||||
|
display_feedback: true,
|
||||||
|
trial_duration: 3000, //Only if display_feedback is false
|
||||||
|
left_category_key: 'e',
|
||||||
|
right_category_key: 'i',
|
||||||
|
left_category_label: ['OLD'],
|
||||||
|
right_category_label: ['YOUNG'],
|
||||||
|
response_ends_trial: true
|
||||||
|
}
|
||||||
|
|
||||||
|
var trial_loop = {
|
||||||
|
timeline: [trial, show_data],
|
||||||
|
loop_function: function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof jsPsych !== "undefined") {
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [preload_trial, 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/plugins/demos/jspsych-image-button-response-demo1.html
Normal file
63
docs/plugins/demos/jspsych-image-button-response-demo1.html
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/jspsych.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-preload.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-html-button-response.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-image-button-response.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/css/jspsych.css">
|
||||||
|
<style>
|
||||||
|
.jspsych-btn {margin-bottom: 10px;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var preload_trial = {
|
||||||
|
type: 'preload',
|
||||||
|
auto_preload: true
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
stimulus: '',
|
||||||
|
choices: ['Run demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var show_data = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
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: 'image-button-response',
|
||||||
|
stimulus: 'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/happy_face_1.jpg',
|
||||||
|
choices: ['Happy', 'Sad'],
|
||||||
|
prompt: "<p>Is this person happy or sad?</p>"
|
||||||
|
};
|
||||||
|
|
||||||
|
var trial_loop = {
|
||||||
|
timeline: [trial, show_data],
|
||||||
|
loop_function: function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof jsPsych !== "undefined") {
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [preload_trial, 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>
|
@ -0,0 +1,63 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/jspsych.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-preload.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-html-button-response.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-image-keyboard-response.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/css/jspsych.css">
|
||||||
|
<style>
|
||||||
|
.jspsych-btn {margin-bottom: 10px;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var preload_trial = {
|
||||||
|
type: 'preload',
|
||||||
|
auto_preload: true
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
stimulus: '',
|
||||||
|
choices: ['Run demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var show_data = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
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: 'image-keyboard-response',
|
||||||
|
stimulus: 'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/happy_face_1.jpg',
|
||||||
|
choices: ['e', 'i'],
|
||||||
|
prompt: "<p>Is this person happy or sad? Press 'e' for happy and 'i' for sad.</p>",
|
||||||
|
};
|
||||||
|
|
||||||
|
var trial_loop = {
|
||||||
|
timeline: [trial, show_data],
|
||||||
|
loop_function: function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof jsPsych !== "undefined") {
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [preload_trial, 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>
|
@ -0,0 +1,63 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/jspsych.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-preload.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-html-button-response.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-image-keyboard-response.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/css/jspsych.css">
|
||||||
|
<style>
|
||||||
|
.jspsych-btn {margin-bottom: 10px;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var preload_trial = {
|
||||||
|
type: 'preload',
|
||||||
|
auto_preload: true
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
stimulus: '',
|
||||||
|
choices: ['Run demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var show_data = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
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: 'image-keyboard-response',
|
||||||
|
stimulus: 'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/happy_face_1.jpg',
|
||||||
|
choices: jsPsych.NO_KEYS,
|
||||||
|
prompt: "<p>Study this face for 5 seconds.</p>",
|
||||||
|
trial_duration: 5000
|
||||||
|
};
|
||||||
|
|
||||||
|
var trial_loop = {
|
||||||
|
timeline: [trial, show_data],
|
||||||
|
loop_function: function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof jsPsych !== "undefined") {
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [preload_trial, 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>
|
62
docs/plugins/demos/jspsych-image-slider-response-demo1.html
Normal file
62
docs/plugins/demos/jspsych-image-slider-response-demo1.html
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/jspsych.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-preload.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-html-button-response.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/plugins/jspsych-image-slider-response.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/css/jspsych.css">
|
||||||
|
<style>
|
||||||
|
.jspsych-btn {margin-bottom: 10px;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var preload_trial = {
|
||||||
|
type: 'preload',
|
||||||
|
auto_preload: true
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
stimulus: '',
|
||||||
|
choices: ['Run demo']
|
||||||
|
};
|
||||||
|
|
||||||
|
var show_data = {
|
||||||
|
type: 'html-button-response',
|
||||||
|
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: 'image-slider-response',
|
||||||
|
stimulus: 'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/happy_face_1.jpg',
|
||||||
|
labels: ['happy', 'sad'],
|
||||||
|
prompt: "<p>How happy/sad is this person?</p>",
|
||||||
|
};
|
||||||
|
|
||||||
|
var trial_loop = {
|
||||||
|
timeline: [trial, show_data],
|
||||||
|
loop_function: function() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof jsPsych !== "undefined") {
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [preload_trial, 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>
|
@ -35,8 +35,10 @@ In addition to the [default data collected by all plugins](/overview/plugins#dat
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
???+ example "Displaying IAT question using html"
|
||||||
|
=== "Code"
|
||||||
```javascript
|
```javascript
|
||||||
var trial_block = {
|
var trial = {
|
||||||
type: 'iat-html',
|
type: 'iat-html',
|
||||||
stimulus: 'Golf',
|
stimulus: 'Golf',
|
||||||
stim_key_association: 'left',
|
stim_key_association: 'left',
|
||||||
@ -51,14 +53,10 @@ var trial_block = {
|
|||||||
right_category_label: ['YOUNG'],
|
right_category_label: ['YOUNG'],
|
||||||
response_ends_trial: true
|
response_ends_trial: true
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeline = [];
|
|
||||||
timeline.push(trial_block);
|
|
||||||
|
|
||||||
jsPsych.init({
|
|
||||||
timeline: timeline,
|
|
||||||
on_finish: function() {
|
|
||||||
jsPsych.data.displayData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
=== "Demo"
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<iframe src="./demos/jspsych-iat-html-demo1.html" width="90%;" height="650px;" frameBorder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a target="_blank" rel="noopener noreferrer" href="./demos/jspsych-iat-html-demo1.html">Open demo in new tab</a>
|
||||||
|
@ -35,6 +35,8 @@ In addition to the [default data collected by all plugins](/overview/plugins#dat
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
???+ example "Displaying IAT question using image files"
|
||||||
|
=== "Code"
|
||||||
```javascript
|
```javascript
|
||||||
var trial_block = {
|
var trial_block = {
|
||||||
type: 'iat-image',
|
type: 'iat-image',
|
||||||
@ -51,14 +53,10 @@ var trial_block = {
|
|||||||
right_category_label: ['YOUNG'],
|
right_category_label: ['YOUNG'],
|
||||||
response_ends_trial: true
|
response_ends_trial: true
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeline = [];
|
|
||||||
timeline.push(trial_block);
|
|
||||||
|
|
||||||
jsPsych.init({
|
|
||||||
timeline: timeline,
|
|
||||||
on_finish: function() {
|
|
||||||
jsPsych.data.displayData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
=== "Demo"
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<iframe src="./demos/jspsych-iat-image-demo1.html" width="90%;" height="650px;" frameBorder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a target="_blank" rel="noopener noreferrer" href="./demos/jspsych-iat-image-demo1.html">Open demo in new tab</a>
|
||||||
|
@ -36,8 +36,8 @@ stimulus | string | The path of the image that was displayed.
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
#### Displaying question until subject gives a response
|
???+ example "Displaying question until subject gives a response"
|
||||||
|
=== "Code"
|
||||||
```javascript
|
```javascript
|
||||||
var trial = {
|
var trial = {
|
||||||
type: 'image-button-response',
|
type: 'image-button-response',
|
||||||
@ -46,3 +46,9 @@ var trial = {
|
|||||||
prompt: "<p>Is this person happy or sad?</p>"
|
prompt: "<p>Is this person happy or sad?</p>"
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
=== "Demo"
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<iframe src="./demos/jspsych-image-button-response-demo1.html" width="90%;" height="600px;" frameBorder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a target="_blank" rel="noopener noreferrer" href="./demos/jspsych-image-button-response-demo1.html">Open demo in new tab</a>
|
||||||
|
@ -33,26 +33,37 @@ In addition to the [default data collected by all plugins](/overview/plugins#dat
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
#### Displaying trial until subject gives a response
|
???+ example "Displaying trial until subject gives a response"
|
||||||
|
=== "Code"
|
||||||
```javascript
|
```javascript
|
||||||
var trial = {
|
var trial = {
|
||||||
type: 'image-keyboard-response',
|
type: 'image-keyboard-response',
|
||||||
stimulus: 'img/happy_face_1.png',
|
stimulus: 'img/happy_face_1.png',
|
||||||
choices: ['e', 'i'],
|
choices: ['e', 'i'],
|
||||||
prompt: "<p>Is this person happy or sad? Press 'e' for happy and 'i' for sad.</p>",
|
prompt: "<p>Is this person happy or sad? Press 'e' for happy and 'i' for sad.</p>",
|
||||||
response_ends_trial: false
|
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
=== "Demo"
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<iframe src="./demos/jspsych-image-keyboard-response-demo1.html" width="90%;" height="600px;" frameBorder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
|
||||||
#### Displaying image for a fixed duration; no response allowed
|
<a target="_blank" rel="noopener noreferrer" href="./demos/jspsych-image-keyboard-response-demo1.html">Open demo in new tab</a>
|
||||||
|
|
||||||
|
???+ example "Displaying image for a fixed duration; no response allowed"
|
||||||
|
=== "Code"
|
||||||
```javascript
|
```javascript
|
||||||
var trial = {
|
var trial = {
|
||||||
type: 'image-button-response',
|
type: 'image-keyboard-response',
|
||||||
stimulus: 'img/happy_face_1.png',
|
stimulus: 'img/happy_face_1.png',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: jsPsych.NO_KEYS,
|
||||||
prompt: "<p>Study this face for 5 seconds.</p>",
|
prompt: "<p>Study this face for 5 seconds.</p>",
|
||||||
trial_duration: 5000
|
trial_duration: 5000
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
=== "Demo"
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<iframe src="./demos/jspsych-image-keyboard-response-demo2.html" width="90%;" height="600px;" frameBorder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a target="_blank" rel="noopener noreferrer" href="./demos/jspsych-image-keyboard-response-demo2.html">Open demo in new tab</a>
|
||||||
|
@ -41,14 +41,19 @@ slider_start | numeric | The starting value of the slider.
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
#### Displaying trial until subject gives a response
|
???+ example "Displaying trial until subject gives a response"
|
||||||
|
=== "Code"
|
||||||
```javascript
|
```javascript
|
||||||
var trial = {
|
var trial = {
|
||||||
type: 'image-slider-response',
|
type: 'image-slider-response',
|
||||||
stimulus: 'img/happy_face_1.png',
|
stimulus: 'img/happy_face_1.png',
|
||||||
labels: ['happy', 'sad'],
|
labels: ['happy', 'sad'],
|
||||||
prompt: "<p>How happy/sad is this person?</p>",
|
prompt: "<p>How happy/sad is this person?</p>",
|
||||||
response_ends_trial: false
|
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
=== "Demo"
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<iframe src="./demos/jspsych-image-slider-response-demo1.html" width="90%;" height="850px;" frameBorder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a target="_blank" rel="noopener noreferrer" href="./demos/jspsych-image-slider-response-demo1.html">Open demo in new tab</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user