Add caption source: https://dl.dropboxusercontent.com/u/44365627/lookangEJSworkspace/export/ejss_src_ElasticCollision.zip run:https://dl.dropboxusercontent.com/u/44365627/lookangEJSworkspace/export/ejss_model_ElasticCollision/ElasticCollision_Simulation.xhtml author: Dave Lommen author of EJS: Francisco Esquembre (Paco) 
http://weelookang.blogspot.sg/2013/09/onedimensioncollisionjsmodel.html
One Dimension Collision JS Model
author: lookang
author EJS: Francisco Esquembre (Paco)

Theory
The motion of a body of mass m and velocity v is described by a vector quantity known as momentum p where
$ p = mv $
When objects collide, whether trains, cars, billiard balls, shopping carts, or your foot and the sidewalk, the results can be complicated. Yet even in the most chaotic of collisions, as long as there are no net external forces acting on the colliding objects, one principle always holds and provides an excellent tool for understanding the collision. That principle is called the conservation of linear momentum which states that
The total momentum of a system remains constant provided that no external resultant force acts on the system.
For two bodies colliding linearly, it is written mathematically as a vector equation
Total initial momentum = total final momentum
$ m_{1}u_{1}+m_{2}u_{2} = m_{1}v_{1}+m_{2}v_{2} $
If external forces (such as friction) are ignored, the total momentum of two carts prior to a collision (left side of equation) is the same as the total momentum of the carts after the collision (right side of equation).
Collisions can be generally classified into these categories:
perfectly inelastic, e= 0
inelastic, e is a value from 0 to 1
perfectly elastic, e=1
There is also a concept of kinetic energy of a moving body is stated mathematically by the following equation:
$ KE_{1} = \frac{1}{2} m_{1}v^{2}_{1} $
Main Simulation View
The simulation has 2 collision carts on frictionless floor.
Sliders
Explore the sliders allows varying the variables .
mass of cart ONE, mass_1, $m_{1}$ in kg
initial velocity of cart ONE, $u_{1}$ in m/s
mass of cart TWO, mass_2, $m_{2}$ in kg
initial velocity of cart TWO, $u_{2}$ in m/s