try{ //rua_script_416 }catch(e){ console.log(e); } if("{{$actual_link}}"){ (function () { var stay_from = new Date(); var send_stay_fired=false; var stay_offset=0; var stay_playing=true; var send_stay = function(fired_check){ var stay=parseInt((new Date()-stay_from)/1000)+stay_offset; console.log(stay); console.log(fired_check); if(fired_check){ if(send_stay_fired){return ;} send_stay_fired=true; } else if(!stay_playing){ return ; } var xhr = new XMLHttpRequest(); var target= "{{$actual_link}}?stay=" + stay; if("{{time()}}"){target+="&time="+"{{time()}}";} try{ xhr.open('GET',target); xhr.send(null); }catch(e){ console.log(e); } return ; }; var stay_pause = function(){ if(stay_playing){ stay_offset=parseInt((new Date()-stay_from)/1000)+stay_offset; stay_from = new Date(); stay_playing=false; } }; var stay_play = function(){ if(!stay_playing&&(stay_offset>0)){ stay_from = new Date(); stay_playing=true; send_stay_fired=false; } }; var skip=0; var skip_count=0; send_stay(false); //setInterval(function(){send_stay(false);},30000); setInterval(function(){ if(++skip_count>skip){ skip_count=0; send_stay(false); } },1000); window.addEventListener("pagehide",function(){send_stay(true);stay_pause();}); window.addEventListener("pageshow",function(){stay_play();}); window.addEventListener("beforeunload",function(){send_stay(true);stay_pause();}); window.addEventListener("blur",function(){send_stay(true);stay_pause();}); window.addEventListener("focus",function(){stay_play();}); window.addEventListener("visibilitychange",function(){ if(document.hidden===true){send_stay(true);stay_pause();} if(document.hidden===false){stay_play();} }); }()); }