zackmdavis/Finetooth — pull request #34 by zackmdavis (2014-10-19 19:03:42+00:00)
Title: compute vote indices clientside

@cookjw

This approach lets us register votes correctly in a way that was impossible under the old strategy (we would just send the text, and have the server try to infer what was actually select, but then if someone voted on a substring that appeared more than once in the votable item, the server would have no way of knowing which occurence was intended). The [Selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection) and [Range](https://developer.mozilla.org/en-US/docs/Web/API/Range) APIs offered by browsers didn't make this as easy as one might have hoped, but some hours of MDN/Google/StackOverflow/thinking-hard research revealed an acceptable solution (see `getVoteSelectionIndices` in finetooth.js): Ranges do know the DOM node (HTML tag or text-outside-of-a-tag) that they start and end in, and their position within that node (character offset in the case of a text node), so we can [traverse](http://en.wikipedia.org/wiki/Tree_traversal) the tags inside of the post's div, counting characters along the way, and taking note of the index where our Range (which we got from the user's selection) starts and ends.

Also, the voting feedback labels use Bootstrap styling now.

Please merge if you find these changes agreeable.