Skip to content

Instantly share code, notes, and snippets.

@Gowiem
Created July 3, 2013 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gowiem/5914647 to your computer and use it in GitHub Desktop.
Save Gowiem/5914647 to your computer and use it in GitHub Desktop.
Hacker News Voting JavaScript
function byId(id) {
return document.getElementById(id);
}
function vote(node) {
var v = node.id.split(/_/); // {'up', '123'}
var item = v[1];
// hide arrows
byId('up_' + item).style.visibility = 'hidden';
byId('down_' + item).style.visibility = 'hidden';
// ping server
var ping = new Image();
ping.src = node.href;
return false; // cancel browser nav
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment