mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
70 lines
2.3 KiB
HTML
70 lines
2.3 KiB
HTML
<!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-animation.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>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/css/jspsych.css">
|
|
<style>
|
|
#jspsych-animation-image {height:80% !important; width: 80% !important;}
|
|
.jspsych-btn {margin-bottom: 10px;}
|
|
</style>
|
|
</head>
|
|
<body></body>
|
|
<script>
|
|
|
|
var jsPsych = initJsPsych();
|
|
|
|
var preload_trial = {
|
|
type: jsPsychPreload,
|
|
auto_preload: true
|
|
}
|
|
|
|
var start = {
|
|
type: jsPsychHtmlButtonResponse,
|
|
stimulus: '',
|
|
choices: ['Run demo']
|
|
};
|
|
|
|
var animation_trial = {
|
|
type: jsPsychAnimation,
|
|
stimuli: [
|
|
'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/happy_face_1.jpg',
|
|
'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/happy_face_2.jpg',
|
|
'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/happy_face_3.jpg',
|
|
'https://cdn.jsdelivr.net/gh/jspsych/jsPsych@6.3.1/examples/img/happy_face_4.jpg'
|
|
],
|
|
sequence_reps: 3,
|
|
frame_time: 300,
|
|
prompt: '<p style="margin-top:0px;">Watch the faces.</p>'
|
|
};
|
|
|
|
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 animation_data_loop = {
|
|
timeline: [animation_trial, show_data],
|
|
loop_function: function() {
|
|
return true;
|
|
}
|
|
};
|
|
|
|
if (typeof jsPsych !== "undefined") {
|
|
jsPsych.run([preload_trial, start, animation_data_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>
|