diff -x .svn -x CVS -urNp countdown/countdown.js countdown.new/countdown.js --- countdown/countdown.js 1969-12-31 19:00:00.000000000 -0500 +++ countdown.new/countdown.js 2007-03-06 20:13:05.671875000 -0500 @@ -0,0 +1,47 @@ +// $Id$ + +var _countdown_accuracy, _countdown_freq, _countdown_interval, _countdown_this; + +function init_countdown(accuracy) { + _countdown_accuracy = String('dhms').indexOf(accuracy); + _countdown_interval = [24, 60, 60, 1]; + _countdown_freq = [86400, 3600, 60, 1]; +} + +if (Drupal.jsEnabled) { + jQuery.fn.extend({ + onready : function() { return this.each(function() { + this.EM = new Array(); + this.initTime = new Array(); + for (i = 0; i < this.childNodes.length; i ++) { + thisChild = this.childNodes.item(i); + if (thisChild.tagName == 'EM') { + this.EM[this.EM.length] = thisChild; + this.initTime[this.initTime.length] = parseInt(thisChild.innerHTML); + } + } + + _countdown_this = this; + setInterval(function() { + for (accuracy = _countdown_accuracy; accuracy >= 0; accuracy --) { + value = _countdown_this.initTime[accuracy]; + if (value || accuracy == 0) { + newValue = value - 1; + } + else { + newValue = _countdown_interval[accuracy - 1] - 1; + } + _countdown_this.initTime[accuracy] = newValue; + _countdown_this.EM[accuracy].innerHTML = String(newValue); + if (value > 0) + break; + } + }, _countdown_freq[_countdown_accuracy] * 1000); + }); } + }); + + $(document).ready(function() { + $(".block-countdown .content").onready(); + } + ); +} diff -x .svn -x CVS -urNp countdown/countdown.module countdown.new/countdown.module --- countdown/countdown.module 2007-03-06 20:19:21.125000000 -0500 +++ countdown.new/countdown.module 2007-03-06 17:34:04.531250000 -0500 @@ -152,25 +152,22 @@ function countdown_block($op = 'list', $ $block['content'] .= t(', %i seconds', array('%i' => $secs_left)); } $block['content'] .= t(($passed) ? ' since %s.' : ' until %s.', array('%s' => variable_get('countdown_event_name', ''))); -/* - $yrs_left = floor($difference/31556926); // 31556926 seconds in a year - $months_left = floor(($difference%31556926)/2629744); // remainder of years into months - 2629744 seconds in month - $days_left = floor((($difference%31556926)%2629744)/86400); // remainder of months into days - 86400 seconds in a day - $hrs_left = floor(((($difference%31556926)%2629744)%86400)/3600); // remainder of days into hours - 3600 seconds in an hour - $min_left = floor((((($difference%31556926)%2629744)%86400)%3600)/60); // remainder of hours into minutes - 60 seconds in a minute - $secs_left = floor((((($difference%31556926)%2629744)%86400)%3600)%60); // remainder of minutes, already in seconds so no need to divide - $block['content'] .= t("%i years ", array('%i' => $yrs_left)); - $block['content'] .= t("%i months ", array('%i' => $months_left)); - $block['content'] .= t("%i days ", array('%i' => $days_left)); - $block['content'] .= t("%i hours ", array('%i' => $hrs_left)); - $block['content'] .= t("%i minutes ", array('%i' => $min_left)); - $block['content'] .= t("%i seconds ", array('%i' => $secs_left)); -*/ + if ($accouracy != 'd') { + $path = drupal_get_path('module', 'countdown'); + drupal_add_js($path . '/countdown.js'); + + $block['content'] .= <<<___EOS___ + +___EOS___; + } + return $block; } break; } } -?> \ No newline at end of file +?>