code changes (php -> javascript)