Forum Replies Created
-
AuthorPosts
-
abraver
ParticipantI gave up on myself too soon! The following works for me, in case anyone else has an Nginx server:
location ~* /experiments { add_header 'Access-Control-Allow-Origin' 'https://expt.pcibex.net'; add_header 'Access-Control-Allow-Methods' 'GET'; add_header 'Access-Control-Allow-Headers' 'X-Accept-Charset,X-Accept,Content-Type'; }
abraver
ParticipantThanks! Unfortunately the server is running Nginx (and that’s not something I can change). I don’t suppose you have the config for Nginx, do you? I’m playing with it at the moment and haven’t had success yet.
abraver
ParticipantMany thanks Jeremy (and thanks for this great tool in general). Works like a charm.
(And re: console.log, I was just making sure that the headphone check script was actually reporting *something* and the issue wasn’t its fault.)
abraver
ParticipantFor more context, here’s the trial in question. I can print the value I’m looking for to the JavaScript console (console.log(data.data.totalCorrect) but I figure out how to get that into the PCIBex log no matter where I put the .log() function, and no matter whether I try to use data.data.totalCorrect as an argument of .log directly, or if I try to set a new variable and call getVar inside of .log.
newTrial("headphonecheck", newButton("check", "Start Heaphone Check") .print() , // This Canvas will contain the test itself newCanvas("headphonecheck", 500,500) .print() , // The HeadphoneCheck module fills the element whose id is "hc-container" newFunction( () => getCanvas("headphonecheck")._element.jQueryElement.attr("id", "hc-container") ).call() , getButton("check") .wait() .remove() , // Create this Text element, but don't print it just yet newText("failure", "Sorry, you failed the heaphone check") , // This is where it all happens newFunction( () => { $(document).on('hcHeadphoneCheckEnd', function(event, data) { getCanvas("headphonecheck").remove()._runPromises(); getButton("dummy").click()._runPromises(); console.log("totalCorrect"); console.log(data.data.totalCorrect); }); HeadphoneCheck.runHeadphoneCheck({totalTrials: 1, trialsPerPage: 1, doCalibration: false // we definitely want to change this for the real one }) }).call() , // This is an invisible button that's clicked in the function above upon success newButton("dummy").wait() )
abraver
ParticipantHi—
I’m trying to implement the code in the above comment, but I’d like to send the result to the log, rather than have the page serve as a gate for people not using headphones.
I’ve tried everything I can think of—for example, setting a newVar inside the function and trying to get that with .log at the end of the trial—but no luck.
How can I get a JavaScript variable from inside a function to be saved to the log?
Thanks in advance.
-
AuthorPosts