PageSourceSearch

https://psych.netlify.app/visual-search-legacy-browsers.js

js psych.netlify.app collected 2026-10-03 11:17:59 UTC 6,657 bytes, 228 lines download raw bytes

1/***************** 
2 * Untitled Test *
3 *****************/
4
5
6// store info about the experiment session:
7let expName = 'untitled';  // from the Builder filename that created this script
8let expInfo = {'participant': '', 'session': '001'};
9
10// Start code blocks for 'Before Experiment'
11// init psychoJS:
12const psychoJS = new PsychoJS({
13  debug: true
14});
15
16// open window:
17psychoJS.openWindow({
18  fullscr: true,
19  color: new util.Color([0, 0, 0]),
20  units: 'height',
21  waitBlanking: true
22});
23// schedule the experiment:
24psychoJS.schedule(psychoJS.gui.DlgFromDict({
25  dictionary: expInfo,
26  title: expName
27}));
28
29const flowScheduler = new Scheduler(psychoJS);
30const dialogCancelScheduler = new Scheduler(psychoJS);
31psychoJS.scheduleCondition(function() { return (psychoJS.gui.dialogComponent.button === 'OK'); }, flowScheduler, dialogCancelScheduler);
32
33// flowScheduler gets run if the participants presses OK
34flowScheduler.add(updateInfo); // add timeStamp
35flowScheduler.add(experimentInit);
36flowScheduler.add(trialRoutineBegin());
37flowScheduler.add(trialRoutineEachFrame());
38flowScheduler.add(trialRoutineEnd());
39flowScheduler.add(quitPsychoJS, '', true);
40
41// quit if user presses Cancel in dialog box:
42dialogCancelScheduler.add(quitPsychoJS, '', false);
43
44psychoJS.start({
45  expName: expName,
46  expInfo: expInfo,
47  resources: [
48  ]
49});
50
51psychoJS.experimentLogger.setLevel(core.Logger.ServerLevel.EXP);
52
53
54var frameDur;
55async function updateInfo() {
56  expInfo['date'] = util.MonotonicClock.getDateStr();  // add a simple timestamp
57  expInfo['expName'] = expName;
58  expInfo['psychopyVersion'] = '2021.2.2';
59  expInfo['OS'] = window.navigator.platform;
60
61  // store frame rate of monitor if we can measure it successfully
62  expInfo['frameRate'] = psychoJS.window.getActualFrameRate();
63  if (typeof expInfo['frameRate'] !== 'undefined')
64    frameDur = 1.0 / Math.round(expInfo['frameRate']);
65  else
66    frameDur = 1.0 / 60.0; // couldn't get a reliable measure so guess
67
68  // add info from the URL:
69  util.addInfoFromUrl(expInfo);
70  
71  return Scheduler.Event.NEXT;
72}
73
74
75var trialClock;
76var text;
77var globalClock;
78var routineTimer;
79async function experimentInit() {
80  // Initialize components for Routine "trial"
81  trialClock = new util.Clock();
82  text = new visual.TextStim({
83    win: psychoJS.window,
84    name: 'text',
85    text: 'Any text\n\nincluding line breaks',
86    font: 'Open Sans',
87    units: undefined, 
88    pos: [0, 0], height: 0.1,  wrapWidth: undefined, ori: 0.0,
89    color: new util.Color('white'),  opacity: undefined,
90    depth: 0.0 
91  });
92  
93  // Create some handy timers
94  globalClock = new util.Clock();  // to track the time since experiment started
95  routineTimer = new util.CountdownTimer();  // to track time remaining of each (non-slip) routine
96  
97  return Scheduler.Event.NEXT;
98}
99
100
101var t;
102var frameN;
103var continueRoutine;
104var trialComponents;
105function trialRoutineBegin(snapshot) {
106  return async function () {
107    TrialHandler.fromSnapshot(snapshot); // ensure that .thisN vals are up to date
108    
109    //------Prepare to start Routine 'trial'-------
110    t = 0;
111    trialClock.reset(); // clock
112    frameN = -1;
113    continueRoutine = true; // until we're told otherwise
114    // update component parameters for each repeat
115    // keep track of which components have finished
116    trialComponents = [];
117    trialComponents.push(text);
118    
119    trialComponents.forEach( function(thisComponent) {
120      if ('status' in thisComponent)
121        thisComponent.status = PsychoJS.Status.NOT_STARTED;
122       });
123    return Scheduler.Event.NEXT;
124  }
125}
126
127
128function trialRoutineEachFrame() {
129  return async function () {
130    //------Loop for each frame of Routine 'trial'-------
131    // get current time
132    t = trialClock.getTime();
133    frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
134    // update/draw components on each frame
135    
136    // *text* updates
137    if (t >= 0.0 && text.status === PsychoJS.Status.NOT_STARTED) {
138      // keep track of start time/frame for later
139      text.tStart = t;  // (not accounting for frame time here)
140      text.frameNStart = frameN;  // exact frame index
141      
142      text.setAutoDraw(true);
143    }
144
145    // check for quit (typically the Esc key)
146    if (psychoJS.experiment.experimentEnded || psychoJS.eventManager.getKeys({keyList:['escape']}).length > 0) {
147      return quitPsychoJS('The [Escape] key was pressed. Goodbye!', false);
148    }
149    
150    // check if the Routine should terminate
151    if (!continueRoutine) {  // a component has requested a forced-end of Routine
152      return Scheduler.Event.NEXT;
153    }
154    
155    continueRoutine = false;  // reverts to True if at least one component still running
156    trialComponents.forEach( function(thisComponent) {
157      if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
158        continueRoutine = true;
159      }
160    });
161    
162    // refresh the screen if continuing
163    if (continueRoutine) {
164      return Scheduler.Event.FLIP_REPEAT;
165    } else {
166      return Scheduler.Event.NEXT;
167    }
168  };
169}
170
171
172function trialRoutineEnd() {
173  return async function () {
174    //------Ending Routine 'trial'-------
175    trialComponents.forEach( function(thisComponent) {
176      if (typeof thisComponent.setAutoDraw === 'function') {
177        thisComponent.setAutoDraw(false);
178      }
179    });
180    // the Routine "trial" was not non-slip safe, so reset the non-slip timer
181    routineTimer.reset();
182    
183    return Scheduler.Event.NEXT;
184  };
185}
186
187
188function endLoopIteration(scheduler, snapshot) {
189  // ------Prepare for next entry------
190  return async function () {
191    if (typeof snapshot !== 'undefined') {
192      // ------Check if user ended loop early------
193      if (snapshot.finished) {
194        // Check for and save orphaned data
195        if (psychoJS.experiment.isEntryEmpty()) {
196          psychoJS.experiment.nextEntry(snapshot);
197        }
198        scheduler.stop();
199      } else {
200        const thisTrial = snapshot.getCurrentTrial();
201        if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {
202          psychoJS.experiment.nextEntry(snapshot);
203        }
204      }
205    return Scheduler.Event.NEXT;
206    }
207  };
208}
209
210
211function importConditions(currentLoop) {
212  return async function () {
213    psychoJS.importAttributes(currentLoop.getCurrentTrial());
214    return Scheduler.Event.NEXT;
215    };
216}
217
218
219async function quitPsychoJS(message, isCompleted) {
220  // Check for and save orphaned data
221  if (psychoJS.experiment.isEntryEmpty()) {
222    psychoJS.experiment.nextEntry();
223  }
224  psychoJS.window.close();
225  psychoJS.quit({message: message, isCompleted: isCompleted});
226  
227  return Scheduler.Event.QUIT;
228}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.