// ----------------------------------------------------- // // Time and Click variables var sPreviousPress = 'Start'; var dPreviousTime = new Date().getTime(); var now = new Date().getTime(); var StartTime = new Date().getTime(); var diff = 0; // ----------------------------------------------------- // // ----------------------------------------------------- // // Function: 1. Creates inputs necessary for Visual Trace // // Inputs: // - btn : Target button, where evenlistener will be added // - sValue : String, value // ----------------------------------------------------- // function InitializeVT(Body,sNameRowsRevealed='sRowsRevealed',sNameTimesRows='sTimesRows') { if (isEmpty(Body)) { Body = document.getElementsByTagName('body')[0]; } // Create hidden input (Revealed Rows) let sRowsRevealed = document.getElementById("sRowsRevealed"); sRowsRevealed.value = ' '; // Create hidden input (Time Buttons) let sTimesRows = document.getElementById("sTimesRows"); sTimesRows.value = ' '; // Create hidden input (Time Buttons) let dTime2First = document.getElementById("dTime2First"); dTime2First.value = ' '; // Append Inputs //Body.appendChild(sRowsRevealed); //Body.appendChild(sTimesRows); //Body.appendChild(dTime2First); } // ----------------------------------------------------- // // Function: 1. scans all buttons with specific class // and converts them to Visual-Tracing Buttons // Inputs: // - sButtonClass : class that encompases buttons to add event listener // - sActivation : Target button, where evenlistener will be added // - sDisplayClass : string with classes that should be activated. // If empty, then activates itself // Outputs: // void // ----------------------------------------------------- / function ConvertButtons2VT(sButtonClass,sActivation='click', sDisplayClass) { lVTbtns = document.getElementsByClassName(sButtonClass); for (let j=0; j=dPreviousTime) { // substract the blurred time diff = (now-dPreviousTime)-(TFocus-TBlur); } else { diff = (now-dPreviousTime); } // Add Time if (sTimesRows.value) { sTimesRows.value = sTimesRows.value+';'+ diff; } else { sTimesRows.value = diff; }; // Replace previous time dPreviousTime = now; } }); } else if (sActivation=='mouseover') { // mouseover btn.addEventListener('mouseover', function() { // If it is the first fixation, record time2first if (sPreviousPress =='Start'){ now = new Date().getTime(); dTime2First.value = now - StartTime; }; // Check that new element is pressed if (btn.id != sPreviousPress) { // Record new time dPreviousTime = new Date().getTime(); // display specific content and hide rest hideEverything(); displayContent(sDisplayClass); // record button pressed if (sRowsRevealed.value) { sRowsRevealed.value = sRowsRevealed.value+';'+btn.id; } else { sRowsRevealed.value = btn.id; }; // change previous to new sPreviousPress = btn.id; } }); // Mouseout btn.addEventListener('mouseout', function() { // Record Event Time now = new Date().getTime(); // Hide the content & Reset previous item sPreviousPress = ' '; hideEverything(); // Check if there is focus checks if (typeof bCheckFocus !== 'undefined' && bCheckFocus==true && TBlur>=dPreviousTime) { // substract the blurred time diff = (now-dPreviousTime)-(TFocus-TBlur); } else { diff = (now-dPreviousTime); } // Add Time if (sTimesRows.value) { sTimesRows.value = sTimesRows.value+';'+ diff; } else { sTimesRows.value = diff; }; console.log(sRowsRevealed,':',sTimesRows); }); } else { console.log('"'+sActivation+'"'+' is not a valid Activation method') } }; // ----------------------------------------------------- // // Function: Display Contents from a specific class // Inputs: // - sClassName : (string) classNames of buttons to be displayed // - sButtonClass : (string) classNames of buttons that can be displayed // ----------------------------------------------------- // function displayContent(sClassName, sButtonClass='btn-outcome') { // Hide everything before hideEverything(); // Load relevant buttons let lBtnGame = document.getElementsByClassName(`${sClassName} ${sButtonClass}`); // Reveal their content for (let i=0; i