A library of useful functions to ease working with instances of constructors.
JavaScript HTML CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


useful.instances.js: Instances Library

A library of useful functions to ease working with instances of constructors.

Try the tests.

How to include the script

This include can be added to the header or placed inline before the script is invoked.

<script src="./js/useful-instances.js"></script>

To enable the use of HTML5 tags in Internet Explorer 8 and lower, include html5.js.

<!--[if lte IE 9]>
	<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>

How to start the script

var instances = new useful.Instances().init({
	'elements' : document.querySelectorAll('#instance-test span'),
	'constructor' : ChangeColor,
	'foo' : 'bar'

elements : {DOM elements} - A collection of DOM elements. i.e. document.getElementsByTagName('A');

constructor : {function} - A constructor for the functionality of the following format: MyConstructor(cfg, parent).

name : {value} - Any number of other name:value pairs to be passed to the constructor.

How to build the script

This project uses node.js from http://nodejs.org/

This project uses gulp.js from http://gulpjs.com/

The following commands are available for development:

  • npm install - Installs the prerequisites.
  • gulp import - Re-imports libraries from supporting projects to ./src/libs/ if available under the same folder tree.
  • gulp dev - Builds the project for development purposes.
  • gulp prod - Builds the project for deployment purposes.
  • gulp watch - Continuously recompiles updated files during development sessions.
  • gulp serve - Serves the project on a temporary web server at http://localhost:8000/ .

How to test the script

These test uses Selenium from http://docs.seleniumhq.org/

  • npm install webdriverjs - Installs the webdriver prerequisite.
  • npm install mocha -g - Installs the prerequisite test framework.
  • java -jar /Applications/Selenium/selenium-server-standalone-2.42.2.jar - Starts Selenium.
  • mocha - Runs the automated tests.


This work is licensed under a Creative Commons Attribution 3.0 Unported License. The latest version of this and other scripts by the same author can be found at http://www.woollymittens.nl/