refactored app.js and api.js.
Merge pull request #7 from paulyi326/dev

refactored app.js and api.js.