mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 10:52:41 +01:00
0569218201
Summary: If `jsxmin` is not available, use a pure PHP implementation instead (JsShrink). Test Plan: - Ran `arc lint --lintall` on all JS and fixed every relevant warning. - Forced minification on and browsed around the site using JS behaviors. Didn't hit anything problematic. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5670
47 lines
1 KiB
JavaScript
47 lines
1 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-countdown-timer
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
*/
|
|
|
|
JX.behavior('countdown-timer', function(config) {
|
|
|
|
var container = JX.$(config.container);
|
|
calculateTimeLeft();
|
|
|
|
function setComponent(which, content) {
|
|
var component = JX.DOM.find(container, '*', 'phabricator-timer-' + which);
|
|
JX.DOM.setContent(component, content);
|
|
}
|
|
|
|
function calculateTimeLeft() {
|
|
var days = 0;
|
|
var hours = 0;
|
|
var minutes = 0;
|
|
var seconds = 0;
|
|
|
|
var current_timestamp = Math.round(new Date() / 1000);
|
|
var delta = config.timestamp - current_timestamp;
|
|
|
|
if (delta > 0) {
|
|
days = Math.floor(delta/86400);
|
|
delta -= days * 86400;
|
|
|
|
hours = Math.floor(delta/3600);
|
|
delta -= hours * 3600;
|
|
|
|
minutes = Math.floor(delta / 60);
|
|
delta -= minutes * 60;
|
|
|
|
seconds = delta;
|
|
|
|
setTimeout(calculateTimeLeft, 1000);
|
|
}
|
|
|
|
setComponent('days', days);
|
|
setComponent('hours', hours);
|
|
setComponent('minutes', minutes);
|
|
setComponent('seconds', seconds);
|
|
}
|
|
});
|
|
|