<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://shutdown.outline.com/static/js/underscore.string.js"></script>
<div class='home-banner jumbotron' id='template-wrapper'>
<h1 class='centered'>The U.S. Federal Government has been shut down for
<u class='number-figure'> </u> days,
<u class='number-figure'> </u> hours,
<u class='number-figure'> </u> minutes,
<u class='number-figure'> </u> seconds </h1>
<h1 class='centered'>and so far it has cost <br>
<u class='number-figure number-figure-huge'></u></h1>
</div>
<script type='text/template' id='banner-template'>
<h1 class='centered'>The U.S. Federal Government has been shut down for
<u class='number-figure'><%= days %></u> day<%= days_pluralize %>,
<u class='number-figure'><%= hours %></u> hour<%= hours_pluralize %>,
<u class='number-figure'><%= minutes %></u> minute<%= minutes_pluralize %>,
<u class='number-figure'><%= seconds %></u> second<%= seconds_pluralize %> </h1>
<h1 class='centered'>and so far it has cost <br>
<u class='number-figure number-figure-huge'><%= cost %>
</u></h1>
</script>
JavaScript
(function loadHomepageJS(){
if (!window.location.href.match(/\/$/)) {
window.location = '/';
}
var template = _.template($('#banner-template').html());
var startDate = 1380600000000; //Math.abs(new Date('2013-10-1 EDT'));
var SECONDS = 1000,
MINUTES = SECONDS * 60,
HOURS = MINUTES * 60,
DAYS = HOURS * 24;
var _s = _.string;
var addCommas = function(str) {
var tmp = _s.reverse(str);
tmp = tmp.replace(/([0-9]{3})/g, '$1,');
var val = _s.reverse(tmp);
if (val[0] === ',') {
val = val.substring(1, val.length);
}
return val;
};
function numberFormat(n) {
var str = Math.round(n) + '';
return '$' + addCommas(str);
}
function updateValues() {
var currentDate = Math.abs(new Date()),
timeDiff = currentDate - startDate;
//console.log('=======>', currentDate, startDate, timeDiff);
var days = Math.floor(timeDiff / DAYS),
hours = Math.floor((timeDiff % DAYS) / HOURS),
minutes = Math.floor((timeDiff % HOURS) / MINUTES),
seconds = Math.floor((timeDiff % MINUTES) / SECONDS);
var cost = timeDiff / HOURS * 12500000;
var vals = {days: days,
hours: hours,
minutes: minutes,
seconds: seconds,
cost: numberFormat(cost),
// Pluralizations
days_pluralize: days === 1 ? '' : 's',
hours_pluralize: hours === 1 ? '' : 's',
minutes_pluralize: minutes === 1 ? '' : 's',
seconds_pluralize: seconds === 1 ? '' : 's'
};
$('#template-wrapper').html(template(vals));
}
updateValues();
window.setInterval(updateValues, 1000);
console.log(HOURS);
})();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.