1

I'm developing a JQM application and need to direct my users back to a login page and clear the local storage after a few minutes on inactivity. Inactivity would be no interactions with the app such a mouse touches or button clicks.

Could someone point me in the right direction with this please.

Thanks

poperob
  • 543
  • 4
  • 21
  • I suppose you can do this same sort of thing in JQM http://stackoverflow.com/questions/667555/detecting-idle-time-in-javascript-elegantly or this http://www.paulirish.com/2009/jquery-idletimer-plugin/ – Ronnie Jun 06 '13 at 20:04
  • Thanks, yes been playing with a few other non JQM methods. Wondered if there was a clean JQM way. But couldn't find anything. – poperob Jun 06 '13 at 20:18
  • Take a look at this: [Detecting idle time in JavaScript elegantly](http://stackoverflow.com/questions/667555/detecting-idle-time-in-javascript-elegantly) – Thomas C. G. de Vilhena Jun 07 '13 at 10:16

1 Answers1

1

OK so i decided to take another route with this as it was a phonegap project and the JavaScript timers stop once the application is sent to the background.

Instead i used the PhoneGap events and then calculated the time difference to time out after 24 hours as per the customer request:

           document.addEventListener("pause", onPause, false);

        function onPause() {


            pausedate = new Date();

        }

        document.addEventListener("resume", onResume, false);

        function onResume() {

            var newhour = 86400000;

            if (((new Date) - pausedate) > newhour)

            {

                logout();
            }

        }
poperob
  • 543
  • 4
  • 21