File "user-stats-page.min.js"

Path: /ThinkIB/mathanalysis/js/user/user-stats-pageminjs
File size: 2.28 KB
MIME-type: text/plain
Charset: utf-8

 
Open Back
var 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()}),1e3*loopSecs),loggerRunning=!0}function stopLogger(){clearInterval(loggerLoop),loggerRunning=!1}function doStats(ini){if("undefined"==typeof activityLogEnabled||!0===activityLogEnabled){null==ini&&(ini=!1),firstInteraction?!1===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(userHash)?localPagesData[userHash]:{},now=new Date;pagesData.hasOwnProperty(lsKey)&&(secs=pagesData[lsKey].secs+secs),pagesData[lsKey]={secs:secs,on:now.toISOString().slice(0,19).replace("T"," "),sdata:sData},localPagesData[userHash]=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+"&ts="+ts,now=new Date;$.post(url,{ini:!0===ini?1:0,secs:secs,on:now.toISOString().slice(0,19).replace("T"," "),sdata:sData},(function(res){"OK"==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(!0),startLogger()})),window.onbeforeunload=function(){doStats()},window.beforeunload=doStats,window.unload=doStats;