Created
October 17, 2014 00:05
-
-
Save jonathansampson/cfdf584c6cc7927da366 to your computer and use it in GitHub Desktop.
Alternative implementation for http://apps.washingtonpost.com/g/page/politics/the-scale-of-american-ebola-infections/1381/?template=iframe which will avoid Stack size limitations in some browsers
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
<style> | |
#people { | |
margin-top: 20px; | |
} | |
#people img { | |
width: 100%; | |
display: block; | |
} | |
</style> | |
<div id="people"></div> | |
<script> | |
(function () { // Online Demo: http://jsfiddle.net/soy6d7pt/1/ | |
"use strict"; | |
var group = 0, groups = 14487, imageElement, | |
fragment = document.createDocumentFragment(), | |
container = document.getElementById( "people" ), | |
affected = Math.floor( Math.random() * groups ), | |
baseURL = "http://www.washingtonpost.com/blogs/the-fix/files/2014/10/"; | |
for ( ; group < groups; group++ ) { | |
imageElement = document.createElement("img"); | |
fragment.appendChild( imageElement ); | |
if ( group === affected ) { | |
imageElement.src = baseURL + "people_inf.png"; | |
continue; | |
} | |
imageElement.src = baseURL + "people_uninf.png"; | |
} | |
container.appendChild( fragment ); | |
}()); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment