apply AMD to refactor js using requirejs