New version - #26
Open
0vulns wants to merge 1 commit into
Open
Conversation
Add multi timers in one page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TimeMe.js
The version of I Support multipurpose using and unlimited Timers on one page.
How do I use TimeMe.js?
First, obtain a copy of timeme.js and ifvisible.js. You can get both by installing TimeMe.js via Bower:
Then, simply include the following lines of code in your page's head element:
This code both imports the TimeMe.js library and initializes it. Notice that this code sets the idle duration to 30 seconds, which means 30 seconds of user inactivity (no mouse or keyboard usage on the page) will stop the timer. Also, we used default timer ID (default).
Once imported and initialized, we can call the various methods made available
by TimeMe.js. See the API documentation below for
a complete breakdown of all of the available functionality. The most basic
feature is to retrieve the time spent by the user on the default timer:
In most cases you will want to store the time spent on a page for analytic purposes. You will therefore need to send the time spent on a page to the server at some point! When is the best time to do this? You can hook into the window.onbeforeunload event to do so. In most browsers this method is fired during a page's shut-down routine. Notice below that we use a synchronous request (not the usual asynchronous request) to guarantee the request to our server arrives before the page closes:
Using 'onbeforeunload' is by no means a requirement. You can hook into any other event or logical point in your application to send the time spent information to the server.
In a traditional if you want another timer on same page without stop or rest the default timer:
All page times are tracked in TimeMe.js, so you can review total aggregate timers on each page for a particular user's session:
API
Sets the Default Timer ID.