Skip to content

Instantly share code, notes, and snippets.

@octagonal
Created June 24, 2013 13:34
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 octagonal/5850086 to your computer and use it in GitHub Desktop.
Save octagonal/5850086 to your computer and use it in GitHub Desktop.
Semantic voting
Sup ilias
From: http://www.reddit.com/r/startups/comments/1gvg7d/show_rstartups_we_were_sick_of_how_stagnant_forum/caodce1:
*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
span.highlighted{
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