Merge pull request #151 from jodeleeuw/master
merge master updates into dev
@ -10,7 +10,7 @@ This page gives a broad overview of how jsPsych works. More detail is available
|
||||
|
||||
## Download jsPsych
|
||||
|
||||
<a href="https://github.com/jodeleeuw/jsPsych/releases/download/v4.2-hotfix.2/jspsych-4.2.zip" class="btn btn-primary" role="button">Download jsPsych v4.2 (zip)</a>
|
||||
<a href="https://github.com/jodeleeuw/jsPsych/releases/download/v4.2-hotfix.4/jspsych-4.2.zip" class="btn btn-primary" role="button">Download jsPsych v4.2 (zip)</a>
|
||||
|
||||
jsPsych is hosted at [GitHub](http://github.com/jodeleeuw/jsPsych). You can find all [jsPsych releases](https://github.com/jodeleeuw/jsPsych/releases) there.
|
||||
|
||||
|
19
jspsych.js
@ -177,7 +177,6 @@
|
||||
|
||||
core.endExperiment = function(){
|
||||
root_chunk.end();
|
||||
finishExperiment();
|
||||
}
|
||||
|
||||
core.endCurrentChunk = function(){
|
||||
@ -284,12 +283,16 @@
|
||||
chunk.next = function() {
|
||||
// return the next trial in the block to be run
|
||||
|
||||
if(this.isComplete()){
|
||||
throw new Error('Tried to get completed trial from chunk that is finished.');
|
||||
} else {
|
||||
return this.timeline[this.currentTimelineLocation].next();
|
||||
// if chunks might need their conditional_function evaluated
|
||||
if(this.type == 'if' && this.currentTimelineLocation == 0){
|
||||
if(!chunk_definition.conditional_function()){
|
||||
this.end();
|
||||
this.parentChunk.advance();
|
||||
return this.parentChunk.next();
|
||||
}
|
||||
}
|
||||
|
||||
return this.timeline[this.currentTimelineLocation].next();
|
||||
};
|
||||
|
||||
chunk.end = function(){
|
||||
@ -322,7 +325,7 @@
|
||||
// linear chunks just go through the timeline in order and are
|
||||
// done when each trial has been completed once
|
||||
// the root chunk is a special case of the linear chunk
|
||||
if(this.type == 'linear' || this.type == 'root'){
|
||||
if(this.type == 'linear' || this.type == 'root' || this.type == 'if'){
|
||||
if (this.currentTimelineLocation >= this.timeline.length) { return true; }
|
||||
else { return false; }
|
||||
}
|
||||
@ -344,7 +347,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
else if(this.type == 'if'){
|
||||
/*else if(this.type == 'if'){
|
||||
if(this.currentTimelineLocation >= this.timeline.length){
|
||||
return true;
|
||||
}
|
||||
@ -358,7 +361,7 @@
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
};
|
||||
|
||||
|
@ -135,19 +135,20 @@
|
||||
|
||||
var after_response = function(info) {
|
||||
|
||||
// check if key is forwards or backwards and update page
|
||||
if(info.key === trial.key_forward || info.key === jsPsych.pluginAPI.convertKeyCharacterToKeyCode(trial.key_forward)){
|
||||
next();
|
||||
}
|
||||
// have to reinitialize this instead of letting it persist to prevent accidental skips of pages by holding down keys too long
|
||||
keyboard_listener = jsPsych.pluginAPI.getKeyboardResponse(after_response, [trial.key_forward, trial.key_backward]);
|
||||
|
||||
// check if key is forwards or backwards and update page
|
||||
if(info.key === trial.key_backward || info.key === jsPsych.pluginAPI.convertKeyCharacterToKeyCode(trial.key_backward)){
|
||||
if(current_page !== 0 && trial.allow_backward) {
|
||||
back();
|
||||
}
|
||||
}
|
||||
|
||||
// have to reinitialize this instead of letting it persist to prevent accidental skips of pages by holding down keys too long
|
||||
keyboard_listener = jsPsych.pluginAPI.getKeyboardResponse(after_response, [trial.key_forward, trial.key_backward]);
|
||||
if(info.key === trial.key_forward || info.key === jsPsych.pluginAPI.convertKeyCharacterToKeyCode(trial.key_forward)){
|
||||
next();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
show_current_page();
|
||||
|
Before Width: | Height: | Size: 234 KiB After Width: | Height: | Size: 234 KiB |
Before Width: | Height: | Size: 231 KiB After Width: | Height: | Size: 231 KiB |
Before Width: | Height: | Size: 339 KiB After Width: | Height: | Size: 339 KiB |
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 177 KiB |