( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<script>
function activityWatcher(){
//The number of seconds that have passed
//since the user was active.
var secondsSinceLastActivity = 0;
//Five minutes. 60 x 5 = 300 seconds.
var maxInactivity = (60 * 1);
//Setup the setInterval method to run
//every second. 1000 milliseconds = 1 second.
setInterval(function(){
secondsSinceLastActivity++;
console.log(secondsSinceLastActivity + ' seconds since the user was last active');
//if the user has been inactive or idle for longer
//then the seconds specified in maxInactivity
if(secondsSinceLastActivity > maxInactivity){
console.log('User has been inactive for more than ' + maxInactivity + ' seconds');
}
else{
var stateX = brandeditor.getState();
brandeditor.http().post('<?php echo $server2; ?>/TheBrandX/mode.php?mode=saveDesignNewInterface&nani=152&themeid=<?php echo $themeid; ?>&userid=<?php echo $userid; ?>', {data: stateX}).subscribe(function(response) {
});
console.log('User has been active and design saved');
}
}, 1000);
//The function that will be called whenever a user is active
function activity(){
//reset the secondsSinceLastActivity variable
//back to 0
secondsSinceLastActivity = 0;
}
//An array of DOM events that should be interpreted as
//user activity.
var activityEvents = [
'mousedown', 'mousemove', 'keydown',
'scroll', 'touchstart'
];
//add these events to the document.
//register the activity function as the listener parameter.
activityEvents.forEach(function(eventName) {
document.addEventListener(eventName, activity, true);
});
}
activityWatcher();
</script>