jsPsych/examples/jspsych-call-function.html
2013-11-11 23:38:37 -05:00

40 lines
1.4 KiB
HTML

<!doctype html>
<html>
<head>
<title>jspsych-call-function 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-call-function.js"></script>
<!-- style -->
<style>
#jspsych_target { margin: 50px auto 50px auto; width: 600px; font-size:18px; text-align: center;}
pre { text-align: left; }
</style>
</head>
<body>
<div id="jspsych_target">
</div>
</body>
<script type="text/javascript">
// this is a simple function that changes the background color of the page
var demo_function = function(color) {
$('body').css({"background-color": color});
return color;
};
// declare the block.
var function_block = {type:'call-function', func: demo_function, args:["#ff0000"]};
jsPsych.init({
display_element: $('#jspsych_target'),
experiment_structure: [function_block],
on_finish:function(data){
$('#jspsych_target').append($("<pre>",{
html: JSON.stringify(data,undefined,2)
}));
}
});
</script>
</html>