File "user-stats-page.min.js"
Path: /StudyIB/js/subjects/activity/user-stats-pageminjs
File size: 2.37 KB
MIME-type: text/plain
Charset: utf-8
var sImg=new Image(1,1),winIn=Date.now(),winOut=!1,accumulatedTime=0,loggerLoop,loggerRunning=!1,firstInteraction=!1,handlerRemoved=!1,firstEvents=["mousedown","mousemove","keypress","scroll","touchstart"];function setFistInteraction(){firstInteraction=!0}function startLogger(){loggerLoop=setInterval((function(){ifvisible.now()&&doStats(sData)}),1e3*loopSecs),loggerRunning=!0}function stopLogger(){clearInterval(loggerLoop),loggerRunning=!1}function doStats(statsMode,ini){null==ini&&(ini=!1),firstInteraction?0==handlerRemoved&&(firstEvents.forEach((function(name){document.removeEventListener(name,setFistInteraction)})),handlerRemoved=!0):(accumulatedTime=0,winIn=Date.now());var secs=Math.floor((Date.now()-winIn+accumulatedTime)/1e3);if("undefined"!=typeof Storage){var localPagesData=JSON.parse(localStorage.getItem("pages")||!1)||{},pagesData=localPagesData&&localPagesData.hasOwnProperty(stdHash)?localPagesData[stdHash]:{},now=new Date;if(pagesData.hasOwnProperty(lsKey)){var on=new Date,secs=pagesData[lsKey].secs+secs;pagesData[lsKey]={sdata:sData,secs:secs,on:on.toISOString().slice(0,19).replace("T"," ")}}else pagesData[lsKey]={sdata:sData,secs:secs,on:now.toISOString().slice(0,19).replace("T"," ")};localPagesData[stdHash]=pagesData,localPagesData.last=now,localPagesData.hasOwnProperty("first")||(localPagesData.first=now),localStorage.setItem("pages",JSON.stringify(localPagesData)),winIn=Date.now(),accumulatedTime=0}else{var ts=Math.round((new Date).getTime()/1e3),url=sAJAX+"&ss="+secs+"&ts="+ts;null==statsMode?(sImg.src=url,winIn=Date.now(),accumulatedTime=0):(secs>=minSecsLog||ini)&&$.post(url,{data:sData},(function(res){"done"==res&&(winIn=Date.now(),accumulatedTime=0)}))}}firstEvents.forEach((function(name){document.addEventListener(name,setFistInteraction)})),ifvisible.on("blur",(function(){!winOut&&firstInteraction&&(accumulatedTime+=Date.now()-winIn,winOut=!0),loggerRunning&&stopLogger()})),ifvisible.on("idle",(function(){!winOut&&firstInteraction&&(accumulatedTime+=Date.now()-winIn,winOut=!0),loggerRunning&&stopLogger()})),ifvisible.on("focus",(function(){winOut&&(winIn=Date.now(),winOut=!1),loggerRunning||startLogger()})),ifvisible.on("wakeup",(function(){winOut&&(winIn=Date.now(),winOut=!1),loggerRunning||startLogger()})),$(document).ready((function(){doStats(sData,!0),startLogger()})),window.onbeforeunload=function(){doStats()},window.beforeunload=doStats,window.unload=doStats;