Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Semantic voting
Sup ilias
*Semantic voting*. You should be able to easily select a section/paragraph of a post/comment,
and vote on it specifically. Instead of voting/liking a complete post
(which probably contains things you agree with as well as things you disagree with),
you can select a word/sentence, and express your agreement.
Downvoting a word could be used to point out grammatical errors, which leads to
<p>A part of this paragraph is <span class=”highlighted” data-highlightValue=”0.1”>highlighted text</span>, as you can see.</p>
<p>No part of this paragraph is highlighted text, as you can see.</p>
//pseudo code
function setHighlight(selection){
int highlightIterationValue = weighted percentage of all votes;
if selection does not have class highlighted{
selection gets <span> tags with class "highlighted" and attribute "data-highlightValue highlightIterationValue";
add to highlightedArray;
} else {
value = data-highlightValue;
value += highlightIterationValue if not higher than one;
data-highlightValue = value;
for all highlightedArray{
background color = highlightColor;
highlightColorSaturation = highlightColorSaturation * data-highlightValue;
push back to DOM;
//pseudo css
background color = highlightColor //if javascript disabled, all highlighted text is fully saturated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.