Refactor js code of the timer, close #45.