Reply To: Refreshing canvas

PennController for IBEX Forums Support Refreshing canvas Reply To: Refreshing canvas


Hi Rafael,

The reasoning is the same here: elements are parts of trials, so when their trial ends, they cease to exist. The only exception is the Var element, which can be made global so you can access and manipulate its value across trials

If you need to keep track of how much time has passed since the beginning of the experiment, you can set a javascript variable to and check it on every trial, for example inside a Header. Here’s an example that will print a 2min timer in the top-left corner of the page, and clear the screen and print a “Timed out!” message when there’s not time left:

ALLOTEDTIME = 2*60*1000
startTime =
toMinSec = v=>Math.floor((ALLOTEDTIME-v)/60000)+":"+Math.floor(((ALLOTEDTIME-v)/1000)%60)

    newText("timer", "").print("left at 2em", "top at 2em")
    newVar("time elapsed")
        .set(v=>>v>ALLOTEDTIME).success( end() )
    newTimer("timeout", 500)
            getVar("time elapsed")
                    newText("Time out!").print()
                    getVar("time elapsed").set(toMinSec)
                    getText("timer").text(getVar("time elapsed"))