mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-13 00:58:12 +00:00
59 lines
2.4 KiB
HTML
59 lines
2.4 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>jspsych-text plugin example</title>
|
|
<!-- jQuery -->
|
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
|
|
<!-- jsPsych -->
|
|
<script src="scripts/jspsych.js"></script>
|
|
<script src="scripts/plugins/jspsych-text.js"></script>
|
|
<!-- style -->
|
|
<style>
|
|
#jspsych_target { margin: 50px auto 50px auto; width: 600px; font-size:18px; text-align: center;}
|
|
#instructions { text-align: left; }
|
|
pre { text-align: left; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="jspsych_target">
|
|
</div>
|
|
</body>
|
|
<script type="text/javascript">
|
|
// declare variable to hold instructions
|
|
var instructions_part_1 = '<div id="instructions"><p>The first part of the instructions. Any HTML code can be used here.</p><p>Press ENTER to continue.</p></div>';
|
|
|
|
// you can also use a function that returns a string as the text parameter.
|
|
// the advantage of this is that the function is evaluated when the text is
|
|
// displayed, so you can show information that depends on things that
|
|
// have happened in the experiment already.
|
|
var instructions_part_2 = function() {
|
|
var d = new Date();
|
|
var n = d.toTimeString();
|
|
return '<div id="instructions"><p>Variables can also be put in the text.</p><p>The current time is '+n+'</p><p>Press ENTER to continue.</p></div>';
|
|
}
|
|
|
|
// create the text block
|
|
var text_block = {type:'text', text: [instructions_part_1,instructions_part_2]};
|
|
|
|
// launch jspsych
|
|
jsPsych.init({
|
|
display_element: $('#jspsych_target'),
|
|
experiment_structure: [text_block],
|
|
on_finish:function(data){
|
|
$('#jspsych_target').append($("<pre>",{
|
|
html: JSON.stringify(data,undefined,2)
|
|
}));
|
|
}
|
|
});
|
|
</script>
|
|
<script>
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
ga('create', 'UA-50563838-1', 'jspsych.org');
|
|
ga('send', 'pageview');
|
|
|
|
</script>
|
|
</html> |