[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 /** 2 * @provides javelin-behavior-countdown-timer 3 * @requires javelin-behavior 4 * javelin-dom 5 */ 6 7 JX.behavior('countdown-timer', function(config) { 8 9 try { 10 var container = JX.$(config.container); 11 } catch (ignored) { 12 return; 13 } 14 15 calculateTimeLeft(); 16 17 function setComponent(which, content) { 18 var component = JX.DOM.find(container, '*', 'phabricator-timer-' + which); 19 JX.DOM.setContent(component, content); 20 } 21 22 function calculateTimeLeft() { 23 var days = 0; 24 var hours = 0; 25 var minutes = 0; 26 var seconds = 0; 27 var partial = 0; 28 29 var current_timestamp = +new Date(); 30 31 var delta = (config.timestamp * 1000) - current_timestamp; 32 33 if (delta > 0) { 34 days = Math.floor(delta / 86400000); 35 delta -= days * 86400000; 36 37 hours = Math.floor(delta / 3600000); 38 delta -= hours * 3600000; 39 40 minutes = Math.floor(delta / 60000); 41 delta -= minutes * 60000; 42 43 seconds = Math.floor(delta / 1000); 44 delta -= seconds * 1000; 45 46 partial = Math.floor(delta / 100) || '0'; 47 48 setTimeout(calculateTimeLeft, 100); 49 } 50 51 setComponent('days', days); 52 setComponent('hours', hours); 53 setComponent('minutes', minutes); 54 setComponent('seconds', [seconds, JX.$N('small', {}, ['.', partial])]); 55 } 56 57 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |