(function( $ ) {
jsPsych.similarity = (function(){
var plugin = {};
plugin.create = function(params) {
sim_stims = params["stimuli"];
trials = new Array(sim_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "similarity";
trials[i]["a_path"] = sim_stims[i][0];
trials[i]["b_path"] = sim_stims[i][1];
trials[i]["timing"] = params["timing"];
}
return trials;
}
plugin.trial = function($this, block, trial, part)
{
switch(part){
case 1:
images = [trial.a_path, trial.b_path];
if(Math.floor(Math.random()*2)==0){
images = [trial.b_path, trial.a_path];
}
// show the images
$this.append($('', {
"src": images[0],
"class": 'sim'
}));
$this.append($('
', {
"src": images[1],
"class": 'sim'
}));
// create slider
$this.append($('