m2m-json: made js code appliable to any forms with class-marked m2m-json input groups; added form submit handler; some comments and cleanup