„Have you ever needed to perform a single or periodic task on your page based on user’s actual presence? Do you think you really need to fetch new notifications from your servers all the time, or isn’t such task quite pointless unless there actually is an active user sitting in front of your page?“
jQuery-IdleCat to the rescue …
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
// Create an instance of idleCat on a jQuery object. var instance = $('#status').idleCat({ // Number of seconds to wait between two scans of user activity. interval: 2, // How many seconds to hold the activity from the moment of knowing there was not any activity. release: 2, // The default state of the idleness (use 'active' or 'idle'). state: 'idle', // Callback fired after the discovery of user activity on the page. activeCallback: function() { $(this).addClass('active'); }, // Callback fired after the discovery of used idleness on the page. // (+ number of seconds defined in the 'release' property) idleCallback: function(element) { $(this).removeClass('active'); }, // See below for more options... }); // Log current state from idleCat attached to that jQuery object. window.setInterval(function() { console.log(instance.getState()); }, 1000) |
Ich bin ein Full-Stack-Entwickler. Meine Expertise umfasst:
Ich liebe die Entwicklung, das Design und kenne mich auch mit Serverarchitekturen aus. Ich würde mich nie vollständig fühlen, wenn einer der Bereiche fehlen würde.
Ich habe ein breites Interessengebiet, deshalb tauche ich ständig in neue Technologien ein und erweitere mein Wissen, wo immer es nötig ist. Die Technologien entwickeln sich schnell und ich genieße es, die neuesten Technologien zu nutzen.
Abgesehen davon bin ich ein friedliebender Kerl, der versucht, Leute um sich herum zu haben, die dasselbe denken. Ich glaube wirklich an das Prinzip: "Wenn man jemandem hilft, wird einem jemand helfen, wenn man es braucht."