Coder Social home page Coder Social logo

facelesslucifer / countable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from radlikewhoa/countable

0.0 2.0 0.0 82 KB

Countable is a JavaScript function to add live paragraph-, word- and character-counting to an HTML element.

Home Page: http://radlikewhoa.github.com/Countable

License: MIT License

countable's Introduction

Countable

Countable is a JavaScript function to add live paragraph-, word- and character-counting to an HTML element. Countable does not rely on any libraries and is very small in size.

View the Demo

Installation

You can install Countable in various ways.

Usage

You can define your own callback function that Countable should use. If you don't pass such a function, the results are simply logged to the console.

<script src="js/Countable.js"></script>
<script>
  new Countable(elem, function (counter) {

    /**
     * `counters.paragraphs` holds the number of paragraphs.
     * `counters.words` holds the number of words.
     * `counters.characters` holds the number of characters (without spaces)
     * `counters.all` holds the number of characters (with spaces)
     */

    alert(counter.paragraphs, counter.words, counter.characters, counters.all);
  });
</script>

Countable takes the value from an HTML element and counts paragraphs, words and characters (without and with spaces). Those numbers are then returned in an object, accessible by a single parameter in the callback function. In the above example, counter holds all numbers returned from Countable.

Browser Support

Countable has been tested in Chrome (latest), Safari (latest), Firefox (latest), Opera (latest) and Internet Explorer (7+). It is built to support both newer and older browsers. Should you find an error, please submit an isssue describing the error, including your browser version and operating system.

About the Author

My name is Sacha Schmid. I'm a front-end engineer from Switzerland. I am the creator of SSGS and other open source projects.

countable's People

Contributors

epmatsw avatar radlikewhoa avatar

Watchers

 avatar  avatar

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.