Last active
November 5, 2015 14:26
-
-
Save johnbocook/aff2f4691d5a8ccd2dde to your computer and use it in GitHub Desktop.
Yearly Abortion counter updated by seconds.
This file contains hidden or 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> | |
| #abCounter { | |
| border:1px solid black; | |
| width:175px; | |
| text-align: center; | |
| font-weight: bold; | |
| font-family: arial, sans-serif; | |
| } | |
| #abCounter #title { | |
| color: white; | |
| background: rgb(0, 0, 153); | |
| margin-top: 0px; | |
| margin-bottom: 0px; | |
| padding-top: 4px; | |
| padding-bottom: 5px; | |
| font-size: 14px; | |
| } | |
| #abcounter #aborts { | |
| font-size: 17px; | |
| color: rgb(153, 0, 0); | |
| padding-top:0px; | |
| padding-bottom:0px; | |
| margin-top:0px; | |
| margin-bottom:0px; | |
| } | |
| </style> |
This file contains hidden or 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
| <html> | |
| <head> | |
| <link type="text/css" rel="stylesheet" href="stylesheet.css" media="all"> | |
| </head> | |
| <body> | |
| <div id="abCounter"> | |
| <p id="title">Yearly Abortion Counter</p> | |
| <p id="aborts">Loading ...</p> | |
| </div> | |
| </body> | |
| <script language="javascript" type="text/javascript"> | |
| function formatNumber(x) { | |
| return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
| } | |
| function abortCount() { | |
| //42 Million per Year http://www.guttmacher.org/pubs/fb_IAW.html | |
| var yearAborts = 42000000; | |
| var yearSeconds = 31536000; | |
| // Setup inital dates. | |
| var now = new Date(); | |
| var year = now.getFullYear(); | |
| // Set current Jan 1st and today | |
| var t1 = new Date(year, 00, 00, 0, 0, 0, 0); | |
| var t2 = now; | |
| // Get current seconds | |
| var dif = t1.getTime() - t2.getTime(); | |
| var secDif = dif / 1000; | |
| var seconds = Math.abs(secDif); | |
| //Counter Math | |
| var aborts = yearAborts / yearSeconds * seconds; | |
| //Format for Output | |
| var currentAborts = Math.round(aborts); | |
| var currentAborts = formatNumber(currentAborts, 1, ',', '.', '', '', '-', '') | |
| //Output | |
| document.getElementById('aborts').innerHTML = currentAborts; | |
| } | |
| //Fire Counter | |
| setInterval(function(){ abortCount() }, 1000); | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment