US anti-terror military death count JavaScript for your site
Monday, 24 September 2007
Three numbers are available with customizable display options. E.g.–
Which adds up to –
Put this in your page
<p> <script type="text/javascript" src="http://sedition.com/js/casualties.js"> </script> </p>
Get this
Only want the number?
<p style="text-align:center"> <script type="text/javascript" src="http://sedition.com/js/casualties.js?text=off"> </script> </p>
Get this
And that, as they say, is that.
The data comes from iCasualties.org. The default display is the sum of their Iraq and Afghanistan numbers. You can set it to return just one or the other. The numbers link back to them, as they should. Those folks work hard on their site and getting it right. Here is their donations page; they broke it and don’t have one you can link directly anymore so…
The numbers displayed by the JavaScript are updated from them often. No guarantees but unless you are checking all day, our version is much more likely to reflect the current values at iCasualties than what you saw the last time you looked.
API, CSS, and placement
The (X)HTML it generates looks something like this (whitespace added)–
<span id="USmilBodyCount"> US military deaths in war on terror: <b><a title="Iraq + Afghanistan casualties" href="http://icasualties.org/">[number]</a></b> </span>
Text in a span
with an id
(in bold above) you can hook with your own style sheet if you choose. The generated (X)HTML is appended to the nodes of whatever parent it sits in. That means it might jump down somewhere you don’t expect or want. If that happens, just wrap it in <p>[script here]</p>
to anchor it as a child, the only one, of that paragraph tag.
Content served as application/xhtml+xml will not be placed correctly. The script self-identification technique used only works if the script can see the DOM as it is loaded; streamlike. In application/xhtml+xml, as other XML, the DOM is only available, atomically, after it has all been loaded.
Allowed arguments in src querystring
- no, the number of fatalities for which country
- no=full, the default, shows both combined
- no=a, for Afghanistan’s number only
- no=i, for Iraq’s number only
- text
- text=on, the default
- text=off, to only show the number
- sep, the separator of the text and number; using it implies you want the text on
- sep=:, the default, for a colon
- sep=n, for an en-dash with whitespace
- sep=m, for an em-dash without whitespace
- sep=br, for an (X)HTML line break, <br/>
Two more examples
<p> <script type="text/javascript" src="http://sedition.com/js/casualties.js?sep=n;no=a"> </script> </p>
<p style="text-align:center"> <script type="text/javascript" src="http://sedition.com/js/casualties.js?text=off;no=i"> </script> </p>
NB
There is no branding (Sedition·com) on it right now. If you want it to stay that way, make sure to mention us if you use it.
Now for some SEO missing above
US military fatalities, troops killed.





