Last active
November 9, 2016 03:22
-
-
Save issa-tseng/0c9e79f2dde907417535cf3518149a44 to your computer and use it in GitHub Desktop.
fivethirtyeight election sorter
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
// press cmd+option+i (or right-click and select inspect element), go to the console, and paste this in: | |
(function() { | |
var value = function(elem) { return ((elem.className.indexOf('close') > 0) ? 1000 : ((elem.className.indexOf('call') > 0) ? -1000 : ((elem.className.indexOf('watch') > 0) ? 1000 : 0))) - $(elem).attr('data-state').charCodeAt(0); }; | |
var dim = function(elem) { if (elem.className.indexOf('call') > 0) $(elem).css('opacity', 0.3); } | |
var go = function() { var states = $('.sparklines .state').get(); states.sort(function(a, b) { return value(b) - value(a); }); var container = $('.sparklines'); states.forEach(function(elem) { container.append(elem); dim(elem); }); }; | |
window.setInterval(go, 30000); | |
$('.switch-toggle').click(function() { window.setTimeout(go, 0); }); | |
go(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment