mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
fix window reference for server-side use
This commit is contained in:
parent
e011ced826
commit
94e884ca1e
14
jspsych.js
14
jspsych.js
@ -495,16 +495,16 @@ var jsPsych = (function() {
|
||||
|
||||
// get all the trials of a particular type
|
||||
this.trialsOfType = function(type) {
|
||||
if (timeline.length == 0) {
|
||||
if (trial_data.type == type) {
|
||||
return trial_data;
|
||||
if (typeof timeline_parameters == 'undefined'){
|
||||
if (trial_parameters.type == type) {
|
||||
return trial_parameters;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
} else {
|
||||
var trials = [];
|
||||
for (var i = 0; i < timeline.length; i++) {
|
||||
var t = timeline[i].trialsOfType(type);
|
||||
for (var i = 0; i < timeline_parameters.timeline.length; i++) {
|
||||
var t = timeline_parameters.timeline[i].trialsOfType(type);
|
||||
trials = trials.concat(t);
|
||||
}
|
||||
return trials;
|
||||
@ -1508,12 +1508,12 @@ jsPsych.pluginAPI = (function() {
|
||||
// audio //
|
||||
|
||||
// temporary patch for Safari
|
||||
if (window.hasOwnProperty('webkitAudioContext') && !window.hasOwnProperty('AudioContext')) {
|
||||
if (typeof window !== 'undefined' && window.hasOwnProperty('webkitAudioContext') && !window.hasOwnProperty('AudioContext')) {
|
||||
window.AudioContext = webkitAudioContext;
|
||||
}
|
||||
// end patch
|
||||
|
||||
var context = (typeof window.AudioContext !== 'undefined') ? new AudioContext() : null;
|
||||
var context = (typeof window !== 'undefined' && typeof window.AudioContext !== 'undefined') ? new AudioContext() : null;
|
||||
var audio_buffers = [];
|
||||
|
||||
module.getAudioBuffer = function(audioID) {
|
||||
|
@ -22,7 +22,8 @@
|
||||
timeline: [
|
||||
{stimulus: 'sound/sound.mp3'},
|
||||
{stimulus: 'sound/hammer.mp3'}
|
||||
]
|
||||
],
|
||||
prompt: 'press any key to advance'
|
||||
}
|
||||
|
||||
jsPsych.init({
|
||||
|
Loading…
Reference in New Issue
Block a user