ported js code to oop

Signed-off-by: Andreas Geibert <ageibert@cemico.de>