JavaScript simulation of the classical XY model