Refactor voting handlers

This pull request reduces code duplication in `app.js` and fixes a bug that was causing the inability to vote the main comment highlighted in the comment page.