Created
October 23, 2011 20:18
-
-
Save eikes/1307837 to your computer and use it in GitHub Desktop.
Hacker News Polls Visualisation JavaScript Bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
var s = document.createElement("script"); | |
s.setAttribute("src", "http://code.jquery.com/jquery.js"); | |
document.body.appendChild(s); | |
s.addEventListener("load", function() { | |
var $ = jQuery; | |
var max = 0; | |
var table = "table tr:eq(3) table:eq(1) "; | |
$(table).width("100%"); | |
$(table + "tr td:eq(0)").width("15px"); | |
$(table + ".comhead span").each(function() { | |
var v = parseInt($(this).text()); | |
if (v > max) max = v; | |
$(this).data("val", v); | |
}).each(function() { | |
$(this) | |
.css({ | |
"width": (100*$(this).data("val")/max)+"%", | |
"background-color":"white", | |
"border": "1px solid black", | |
"display": "block" | |
}); | |
}); | |
}); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){var a=document.createElement("script");a.setAttribute("src","http://code.jquery.com/jquery.js");document.body.appendChild(a);a.addEventListener("load",function(){var b=jQuery,a=0;b("table tr:eq(3) table:eq(1) ").width("100%");b("table tr:eq(3) table:eq(1) tr td:eq(0)").width("15px");b("table tr:eq(3) table:eq(1) .comhead span").each(function(){var c=parseInt(b(this).text());c>a&&(a=c);b(this).data("val",c)}).each(function(){b(this).css({width:100*b(this).data("val")/a+"%","background-color":"white",border:"1px solid black",display:"block"})})})})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment