rewrite javascript with haxe