Update pins when clicked

Split JavaScript into a separate file