Completed translation to Endpoints API in Javascript. Not bug checked.