PennController for IBEX › Forums › Support › Preloading resources by experiment list › Reply To: Preloading resources by experiment list
February 15, 2021 at 5:50 pm
#6613
Jeremy
Keymaster
My bad, I tested my code at https://farm.pcibex.net/, where __counter_value_from_server__ is accessible from the start, which is not the case at https://expt.pcibex.net.
If you’re running your study on the expt Farm (or on the original Ibex Farm for that matter) you’ll need a little trick to detect when __counter_value_from_server__ is being set:
let myOwnCounter = 0, preloadZipSent = false; Object.defineProperty(window, '__counter_value_from_server__', { set(v){ myOwnCounter = v; if (preloadZipSent) return; preloadZipSent = true; switch (v % 4) { case 0: PreloadZip("https://my.server/path/to/zip_a.zip"); break; case 1: PreloadZip("https://my.server/path/to/zip_b.zip"); break; case 2: PreloadZip("https://my.server/path/to/zip_c.zip") break; default: case 3: PreloadZip("https://my.server/path/to/zip_d.zip") break; } }, get(){ return myOwnCounter; } });
Jeremy