refactor upvote javascript