generate gallery javascript