quest: refactor javascript.

Add some helper function to make code more clean, and add some comment.
Something rely on css class to switch to id, almost everything had done,
but the display of question answering state hadn't.