Merge pull request #69 from jodeleeuw/dev-chunks

Dev chunks
This commit is contained in:
Josh de Leeuw 2014-09-23 16:47:27 -04:00
commit ac5c707516
18 changed files with 1175 additions and 966 deletions

1997
jspsych.js

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -114,17 +114,17 @@
jsPsych.pluginAPI.cancelKeyboardResponse(response_listener);
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"animation_sequence": JSON.stringify(animation_sequence),
"responses": JSON.stringify(responses)
}, trial.data));
if(trial.timing_post_trial > 0){
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
}
};

View File

@ -21,15 +21,15 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
var return_val = trial.func.apply({}, [trial.args]);
if (typeof return_val !== 'undefined') {
block.writeData($.extend({},{
jsPsych.data.write($.extend({},{
value: return_val
},trial.data));
}
block.next();
jsPsych.finishTrial();
};
return plugin;

View File

@ -32,7 +32,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -135,7 +135,7 @@
"key_press": info.key
};
block.writeData($.extend({}, trial_data, trial.data));
jsPsych.data.write($.extend({}, trial_data, trial.data));
jsPsych.pluginAPI.cancelKeyboardResponse(keyboard_listener);
@ -148,10 +148,10 @@
display_element.html(''); // clear everything
if(trial.timing_post_trial > 0){
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
}
};

View File

@ -37,7 +37,7 @@
var cat_trial_complete = false;
plugin.trial = function(display_element, block, trial, part) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -95,7 +95,7 @@
"key_press": info.key
};
block.writeData($.extend({}, trial_data, trial.data));
jsPsych.data.write($.extend({}, trial_data, trial.data));
display_element.html('');
@ -157,10 +157,10 @@
display_element.html("");
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
}

View File

@ -31,7 +31,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -116,7 +116,7 @@
});
});
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"init_locations": JSON.stringify(init_locations),
"moves": JSON.stringify(moves),
"final_locations": JSON.stringify(final_locations),
@ -127,11 +127,11 @@
display_element.html("");
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
}
else {
block.next();
jsPsych.finishTrial();
}
}
}));

View File

@ -29,7 +29,7 @@ documentation: https://github.com/jodeleeuw/jsPsych/wiki/jspsych-html
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -46,7 +46,7 @@ documentation: https://github.com/jodeleeuw/jsPsych/wiki/jspsych-html
var finish = function() {
if (trial.check_fn && !trial.check_fn(display_element)) return;
if (trial.cont_key) $(document).unbind('keydown', key_listener);
block.writeData({
jsPsych.data.write({
rt: (new Date()).getTime() - t0,
url: trial.url
});
@ -56,12 +56,12 @@ documentation: https://github.com/jodeleeuw/jsPsych/wiki/jspsych-html
setTimeout(function() {
display_element.empty();
display_element.show();
block.next();
jsPsych.finishTrial();
}, trial.timing);
}
else {
display_element.empty();
block.next();
jsPsych.finishTrial();
}
};
if (trial.cont_btn) $('#' + trial.cont_btn).click(finish);

View File

@ -43,7 +43,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -257,7 +257,7 @@
var n_diff = arrayDifferences(trial.configurations, lineIsVisible);
var correct = (n_diff === 0);
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"configuration": JSON.stringify(lineIsVisible),
"target_configuration": JSON.stringify(trial.configurations),
"rt": response_time,
@ -302,11 +302,11 @@
// next trial
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
}
else {
block.next();
jsPsych.finishTrial();
}
}

View File

@ -37,7 +37,7 @@
var sd_trial_complete = false;
plugin.trial = function(display_element, block, trial, part) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -122,16 +122,16 @@
"stimulus_2": trial.b_path,
"key_press": info.key
};
block.writeData($.extend({}, trial_data, trial.data));
jsPsych.data.write($.extend({}, trial_data, trial.data));
display_element.html('');
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
}

View File

@ -40,7 +40,7 @@
var sim_trial_complete = false;
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -63,7 +63,7 @@
}
if (trial.show_response == "FIRST_STIMULUS") {
show_response_slider(display_element, trial, block);
show_response_slider(display_element, trial);
}
setTimeout(function() {
@ -91,7 +91,7 @@
$('#jspsych_sim_stim').css('visibility', 'visible');
if (trial.show_response == "SECOND_STIMULUS") {
show_response_slider(display_element, trial, block);
show_response_slider(display_element, trial);
}
if (trial.timing_second_stim > 0) {
@ -99,7 +99,7 @@
if (!sim_trial_complete) {
$("#jspsych_sim_stim").css('visibility', 'hidden');
if (trial.show_response == "POST_STIMULUS") {
show_response_slider(display_element, trial, block);
show_response_slider(display_element, trial);
}
}
}, trial.timing_second_stim);
@ -107,7 +107,7 @@
}
function show_response_slider(display_element, trial, block) {
function show_response_slider(display_element, trial) {
var startTime = (new Date()).getTime();
@ -195,7 +195,7 @@
var response_time = endTime - startTime;
sim_trial_complete = true;
var score = $("#slider").slider("value");
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"sim_score": score,
"rt": response_time,
"stimulus": trial.a_path,
@ -205,10 +205,10 @@
display_element.html('');
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
});
}

View File

@ -38,7 +38,7 @@
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -85,7 +85,7 @@
"key_press": info.key
};
block.writeData($.extend({}, trial_data, trial.data));
jsPsych.data.write($.extend({}, trial_data, trial.data));
// clear the display
display_element.html('');
@ -93,10 +93,10 @@
// move on to the next trial
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
};

View File

@ -29,7 +29,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -143,7 +143,7 @@
});
// save data
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"rt": response_time
}, question_data, trial.data));
@ -151,9 +151,9 @@
// next trial
if(trial.timing_post_trial > 0){
setTimeout(function(){ block.next(); }, trial.timing_post_trial);
setTimeout(function(){ jsPsych.finishTrial(); }, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
});

View File

@ -26,7 +26,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -70,7 +70,7 @@
});
// save data
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"rt": response_time
}, question_data, trial.data));
@ -78,9 +78,9 @@
// next trial
if(trial.timing_post_trial > 0){
setTimeout(function(){ block.next(); }, trial.timing_post_trial);
setTimeout(function(){ jsPsych.finishTrial(); }, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
});

View File

@ -27,7 +27,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -45,12 +45,12 @@
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
}
else {
block.next();
} // call block.next() to advance the experiment after a delay.
jsPsych.finishTrial();
}
};
@ -73,7 +73,7 @@
}
function save_data(key, rt) {
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"rt": rt,
"key_press": key
}, trial.data));

View File

@ -41,7 +41,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
trial = jsPsych.pluginAPI.normalizeTrialVariables(trial);
@ -169,15 +169,15 @@
// this line merges together the trial_data object and the generic
// data object (trial.data), and then stores them.
block.writeData($.extend({}, trial_data, trial.data));
jsPsych.data.write($.extend({}, trial_data, trial.data));
// go to next trial
if(trial.timing_post_trial > 0){
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
}
};

View File

@ -35,7 +35,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -144,18 +144,18 @@
jsPsych.pluginAPI.cancelKeyboardResponse(key_listener);
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"stimuli": JSON.stringify(trial.stims),
"responses": JSON.stringify(responses)
}, trial.data));
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
}
else {
block.next();
jsPsych.finishTrial();
}
}
};

View File

@ -31,7 +31,7 @@
return trials;
};
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -48,17 +48,17 @@
display_element.html('');
block.writeData($.extend({}, {
jsPsych.data.write($.extend({}, {
"stimuli": JSON.stringify(trial.stimuli)
}, trial.data));
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
}
else {
block.next();
jsPsych.finishTrial();
}
}
};

View File

@ -48,7 +48,7 @@
var xab_trial_complete = false;
plugin.trial = function(display_element, block, trial) {
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
@ -162,7 +162,7 @@
"stimulus_b": trial.b_path,
"key_press": info.key
};
block.writeData($.extend({}, trial_data, trial.data));
jsPsych.data.write($.extend({}, trial_data, trial.data));
display_element.html(''); // remove all
@ -171,10 +171,10 @@
// move on to the next trial after timing_post_trial milliseconds
if (trial.timing_post_trial > 0) {
setTimeout(function() {
block.next();
jsPsych.finishTrial();
}, trial.timing_post_trial);
} else {
block.next();
jsPsych.finishTrial();
}
};