Created
October 31, 2013 02:34
-
-
Save schneidan/7243581 to your computer and use it in GitHub Desktop.
Widget counts down until the first Denver Broncos game of the NFL season (2013 edition)
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
<script type="text/javascript" src="http://extras.denverpost.com/media/js/jquery-min.js"></script> | |
<span class="countdownform"></span> | |
<script type="text/javascript"> | |
var current=""; | |
var year=2013; | |
var month=09; | |
var day=5; | |
var hour=18; | |
var minute=30; | |
var tz=-6; | |
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); | |
function pad(d) { | |
return (d < 10) ? '0' + d.toString() : d.toString(); | |
} | |
function countdown(yr,m,d,hr,min){ | |
theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min; | |
var today=new Date(); | |
var todayy=today.getYear(); | |
if (todayy < 1000) { | |
todayy+=1900; } | |
var todaym=today.getMonth(); | |
var todayd=today.getDate(); | |
var todayh=today.getHours(); | |
var todaymin=today.getMinutes(); | |
var todaysec=today.getSeconds(); | |
var todaystring1=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec; | |
var todaystring=Date.parse(todaystring1)+(tz*1000*60*60); | |
var futurestring1=(montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min); | |
var futurestring=Date.parse(futurestring1)-(today.getTimezoneOffset()*(1000*60)); | |
var dd=futurestring-todaystring; | |
var dday=pad(Math.floor(dd/(60*60*1000*24)*1)); | |
var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1); | |
var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1); | |
var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1); | |
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){ | |
$('.countdownform').css('display', 'none'); | |
return; | |
} | |
else { | |
if (dhour>=0) { ddhour = dhour + ' hr., '; } else { ddhour = ''; } | |
if (dmin>=0) { ddmin = dmin + ' min., '; tweetmin = dmin + 'min.:'; } else { ddmin = ''; } | |
if (dsec>=0) { ddsec = dsec + ' sec. '; } else { ddsec = ''; } | |
$('.countdownform').html(ddhour + ddmin + ddsec); | |
setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",1000); | |
} | |
} | |
countdown(year,month,day,hour,minute); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment