Giter VIP home page Giter VIP logo

idle.js's Introduction

Build Status

Idle.Js

NuGet

Visual Studio users can install this directly into their web projects by executing the following command in the Package Manager Console

PM> Install-Package Idle.js

Web Component

Polymer wrapper is available here.

Description

Tiny javascript library to report activity of user in the browser (away, idle, not looking at webpage, etc). that is independent of any other javascript libraries such as jquery.

You can view the demo here.

Changelog

0.0.2 (19-11-14) - Bower Support

0.0.2 (7-03-12) - Added 2 events for the visibility API. Now detects when is a user changes tabs or returns.

0.0.1 - Initial activity monitoring.

idle.js's People

Contributors

shawnmclean avatar mkazlauskas avatar msanjdev avatar laurynasra avatar justintulloss avatar glennvd avatar jarvizx avatar snayagar avatar lihas avatar

Stargazers

Jonas Schönbach avatar Akhmed Ibragimov avatar Liychen avatar  avatar Michael avatar Jared Van Valkengoed avatar Felix Kaspar avatar Shane avatar Boro Vukovic avatar Stefan-Alexander Scholz avatar Namit Chadha avatar Pawan Kumar Singh avatar Simranjeet Singh avatar Shyam Bheda avatar  avatar sang avatar Akshay Bande avatar  avatar Dmitriy Nyashkin avatar Ya-Che Li avatar Juan avatar Chaitanya Chinni avatar Hugo Barbosa avatar Jacob Marshall avatar Doan Thi Ngoc Lan avatar İsmail Hakkı Türkmen avatar Ahmed Khusaam avatar Baku avatar betgar avatar  avatar Nicolas Binet avatar Ke.shidong avatar  avatar Nuttapol Phomthon avatar Jigar Chavada avatar Fabrício Ziliotti avatar Nitin Khanna avatar Karol Milewski avatar Tony Xiao avatar Kal An Zans avatar Joshy Francis avatar Elliott Zheng avatar  avatar  avatar Hieu Huynh avatar Iurii Alekseev avatar Jason Antwi-Appah avatar Oscar Lozano avatar zhe wu avatar Ahmed Şeref avatar Daniel Sirakov avatar  avatar Varun M avatar asidpulse avatar Amadeo Gallardo avatar Nguyen Nhut Truong avatar Xiaomin Yu avatar Cameron Kloot avatar Sachin Makasana avatar  avatar Bart Stefanski avatar Anatoli Makarevich avatar Elliot Lings avatar Chris avatar Glauber Righes avatar George Lima avatar Eduardo Stuart avatar Lucas Alexander Floriani avatar Marcelo Formentão avatar Willian Justen  avatar Vlad Sabev avatar  avatar Samvit Majumdar avatar Riley Paulsen avatar Nathan Hutchision avatar Elawady Elsayd avatar Neal Audenaert avatar Mattias Hising avatar TrucTH avatar Tim McKinley avatar 李力 avatar Jojo Narte avatar Bharat Mandava avatar Edison Alba  avatar Gaspar Argüello avatar Asad Dhamani avatar Emeson Pereira avatar  avatar Guilherme Felix da Silva Maciel avatar Eyüp avatar Behzad Khosravifar avatar Adrian D. Alvarez avatar Sam avatar Mikal avatar Asif Rahman avatar Jackson Geller avatar Erhan avatar Javier Rosas avatar Kirill Malyshev avatar Dilnoor avatar

Watchers

Cody Finegan avatar Patrice Boissonneault avatar Paulo dos Santos avatar Pablo Targa avatar Nicolaus Copernicus avatar Brandon Wittwer avatar Michal Kechner avatar James Cloos avatar Purusothaman Ramanujam avatar John Dave Decano avatar Gerardo avatar Kris Gutta avatar Robrecht Wellens avatar JUNO_OKYO avatar TrucTH avatar  avatar acte avatar Stillhart avatar dung.vu avatar Carbon-Based Lifeform avatar  avatar

idle.js's Issues

startAwayTimeout does not exist

When building idle.js there is a call to startAwayTimeout() but this function doesn't exist.

Using the idle.js version from the live demo it works fine.

onfocus = active?

First, thanks for sharing this, very useful.

I was wondering... have you ever thought about raising the "back" or "active" event when the browser comes back in focus?

I'm asking because right now, if you switch window using ctrl-tab for example, when you come back to your browser, I'd like to see the active event firing back again.

Just a thought, great plugin!

Patrice

Idle.js interprets page navigation in Firefox as being "away"

If you go to http://shawnmclean.github.io/Idle.js/ in Firefox and refresh the page, you'll briefly see idle.js report that "User is not looking at page" before the page repaints. This is also happening in a dashboard app that I have whenever a user clicks on any link that takes them away from the dashboard - the "background polling paused" message I have setup is displayed for a second while Firefox is busy loading the new page.

Document Supported Browsers

This script looks/works good, and I'm sure the documentation will come when you release a beta.

But when you get to that point (or sooner) please document the browsers you have tested in.

Tested http://shawnmclean.github.io/Idle.js/

PASS::
Windows 7:
Firefox 20.0.1
Chrome Version 27.0.1453.73 beta-m
IE 10

FAIL::
Windows XP:
IE 8

SCRIPT438: Object doesn't support property or method 'addEventListener'
idle.js, line 43 character 7

I've committed to compatibility down to ie8. Unfortunately this fails in ie8. To get rid of the above error i added:

        if (document.addEventListener) {
            document.addEventListener("visibilitychange", (function () {
                return activity.handleVisibilityChange();
            }), false);
            document.addEventListener("webkitvisibilitychange", (function () {
                return activity.handleVisibilityChange();
            }), false);
            document.addEventListener("msvisibilitychange", (function () {
                return activity.handleVisibilityChange();
            }), false);
        } else {
            document.attachEvent("onvisibilitychange", (function () {
                return activity.handleVisibilityChange();
            }));
        }

This will then run, but it doesn't work. I will see if i can figure out some more fixes.

ES6 and NPM packages

Hi @shawnmclean Thanks for providing IdleJS.

I am trying to integrate Idle in our applications, but I encountered some problems. We are using ES6/Webpack.

I download a copy of idle.js, when import it , none of the following are working.

import './idle';
import Idle from './idle';
import * as Idle from './idle';

Can you provide some suggestion?

BTW, I can not find this lib in NPM, it is not published to NPM?

vendor-prefixed `visibilitychange` event listener is called the second time in newer browsers

In the code for Idle.js, There are several vendor-prefixed events setup on the same listener for the visibilitychange event. This makes it fire twice in (newer) browsers that support both the older vendor-prefixed events and the newer unprefixed events. I have corrected this in my personal build of Idle.js and would have made a pull request but i don't know how to write coffeescript (which is the source language of choice for Idle.js ). However, here's my code snippet to remedy this in plain JavaScript

        if(typeof document.addEventListener === 'function'){
          
            if('hidden' in document &&
              !('webkitHidden' in document
                  || 'oHidden' in document
                    || 'mozHidden' in document
                        || 'msHidden' in document)){
                         document.addEventListener("visibilitychange", this.listener, false);
            }else{
                        document.addEventListener("webkitvisibilitychange", this.listener, false);
                        document.addEventListener("msvisibilitychange", this.listener, false);
            }
        }
        .
        .
        .
        if(typeof document.removeEventListener === 'function'){
            if('hidden' in document &&
                  !('webkitHidden' in document
                      || 'oHidden' in document
                        || 'mozHidden' in document
                            || 'msHidden' in document)){
                        document.removeEventListener("visibilitychange", this.listener);
            }else{
                       document.removeEventListener("webkitvisibilitychange", this.listener);
                       document.removeEventListener("msvisibilitychange", this.listener);
           }
        }

Touch events support

It appears this lib doesn't take into account touch events (am I wrong?).

It would be nice.

Document API

Library looks pretty solid, but it really needs documentation on the behavior and interface.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.