https://github.com/selectnull/jquery-readingstats
jQuery plugin to calculate reading stats (word count, reading time)
https://github.com/selectnull/jquery-readingstats
Last synced: 11 months ago
JSON representation
jQuery plugin to calculate reading stats (word count, reading time)
- Host: GitHub
- URL: https://github.com/selectnull/jquery-readingstats
- Owner: selectnull
- License: mit
- Created: 2012-07-30T17:53:27.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-03-15T13:34:27.000Z (almost 12 years ago)
- Last Synced: 2025-02-24T02:55:37.409Z (11 months ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
===========================
jQuery reading stats plugin
===========================
jQuery reading stats plugin, v1.0
Use it to calculate and display time to read a piece of text,
eg a blog post.
How to use it?
==============
There are two arguments and both are optional. The first is options object
with which you can customize reading speed (in words per minute) and
formatter funtion to display the result.
* *readingSpeed*, default value is 200 words per minute
* *format*, formatter function that takes a number (of seconds)
and returns a string like 2 min 45 sec
There are two ways to call it. First is to get
result directly, like this:
var rs = $('#my-content').readingStats({
readingSpeed: 100,
format: function (x) {return x.toString() + ' sec';}
});
console.log(rs.wordCount); // word count
console.log(rs.secondsToRead); // number of seconds
console.log(rs.format()); // formatted output
If you want to do something else with selector, you can specify
callback function as second argument and chain whatever
jQuery methods after it.
$('#my-content').readingStats({readingSpeed: 240}, function (stats) {
console.log(stats);
// do something with stats object
}
).fadeOut().fadeIn();
Licence
=======
The code is MIT licensed.