JavaScript code created in a more generic format

Signed-off-by: Matthew Rayner <matt@mattrayner.co.uk>