So I am a total JS novice, but I had someone write some code to be used within Qualtics survey. That code is now broken and I am trying to fix it up, there is an error with this line:
var timingObj=${e://Field/TimingObj};
I was hoping someone could help explain this line to me so I may be able to fix it up. (I have to full code, but that seemed a bit long to have someone go through.) I understand the first part is setting the variable named timingobj equal to something.
What that is is confusing to me, especially with the "//" which I understand to denote a note and not code. This code had worked in the past but now gives me an error. Any help understanding what I am working with would be amazing.
Thanks!
Update full code as provided to me:
//configurations
var bindInterval=10;
//initiate
var timingObj=${e://Field/TimingObj};
timingObj.version=3;
var startTiming=function(tag){
var currentTimeObj=timingObj[tag];
if (!currentTimeObj) {
currentTimeObj={};
currentTimeObj.startTimes=[];
currentTimeObj.elapseTimes=[];
currentTimeObj.totalElapsed=0;
timingObj[tag]=currentTimeObj;
}
var time=(new Date()).getTime();
currentTimeObj.startTimes.push(time);
currentTimeObj.startTime=time;
timingObj.activateTag=tag;
};
var closePopupCallback=function(){
//stop timing
var time=(new Date()).getTime();
var currentTag = timingObj.activateTag;
var currentTimeObj = timingObj[currentTag];
var elapsed=time - currentTimeObj.startTime;
currentTimeObj.elapseTimes.push(elapsed);
var totalElapsed=currentTimeObj.totalElapsed + elapsed;
currentTimeObj.totalElapsed=totalElapsed;
Qualtrics.SurveyEngine.setEmbeddedData(currentTag+'_Time',totalElapsed);
Qualtrics.SurveyEngine.setEmbeddedData(currentTag+'_Count',currentTimeObj.startTimes.length);
var timingObjSerialized=Object.toJSON(timingObj);
Qualtrics.SurveyEngine.setEmbeddedData('TimingObj',timingObjSerialized);
};
var bindCloseEvent=function() {
//window.document.observe('dom:loaded',func) and document.observe('dom:loaded',func) did not work
var closeButton=$('bottomNavClose');
if (closeButton) {
closeButton.observe('click', closePopupCallback);
} else{
setTimeout(bindCloseEvent,bindInterval);
}
};
// bad smell
var bindLightBoxCloseEvent=function(){
var lightBox=$('lightbox');
if (lightBox) {
lightBox.observe('click', closePopupCallback);
} else{
setTimeout(bindLightBoxCloseEvent,bindInterval);
}
};
bindLightBoxCloseEvent();
bindCloseEvent();
Qualtrics.SurveyEngine.addOnload(function(){
});