Creating event vector in javascript