Refactor js in news site