abraver

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: Many audio stimuli in Safari #6130
    abraver
    Participant

    I 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';
    }
    in reply to: Many audio stimuli in Safari #6129
    abraver
    Participant

    Thanks! 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.

    in reply to: html code with embedded script #5871
    abraver
    Participant

    Many 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.)

    in reply to: html code with embedded script #5866
    abraver
    Participant

    For 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()
        
    )
    
    in reply to: html code with embedded script #5865
    abraver
    Participant

    Hi—

    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.

Viewing 5 posts - 1 through 5 (of 5 total)