diff -x '*.patch' -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-07 07:43:53.562500000 -0500 @@ -0,0 +1,86 @@ +// $Id$ + +var _countdown_accuracy, _countdown_freq, _countdown_interval, _countdown_direction, _countdown_this; + +function init_countdown(accuracy) { + _countdown_accuracy = String('dhms').indexOf(accuracy); + _countdown_interval = [24, 60, 60, 1]; + _countdown_freq = [86400, 3600, 60, 1]; + _countdown_direction = -1; +} + +if (Drupal.jsEnabled) { + function countUp() { + _countdown_this.objDirText.nodeValue = _countdown_this.objDirText.nodeValue.replace(' until', ' since'); + _countdown_direction = 1; + _countdown_this.initTime[0] = 0; + _countdown_this.initTime[1] = 0; + _countdown_this.initTime[2] = 0; + _countdown_this.initTime[3] = 0; + _countdown_this.objEM[0].innerHTML = String('0'); + _countdown_this.objEM[1].innerHTML = String('0'); + _countdown_this.objEM[2].innerHTML = String('0'); + _countdown_this.objEM[3].innerHTML = String('0'); + } + + jQuery.fn.extend({ + onready : function() { return this.each(function() { + this.objEM = new Array(); + this.initTime = new Array(); + for (i = 0; i < this.childNodes.length; i ++) { + thisChild = this.childNodes.item(i); + if (thisChild.tagName == 'EM') { + this.objEM[this.objEM.length] = thisChild; + this.initTime[this.initTime.length] = parseInt(thisChild.innerHTML); + } + else if (thisChild.nodeName == '#text') { + if (thisChild.nodeValue.indexOf(' since') >= 0) { + _countdown_direction = 1; + this.objDirText = thisChild; + } + else if (thisChild.nodeValue.indexOf(' until') >= 0) { + this.objDirText = thisChild; + } + } + } + + _countdown_this = this; + setInterval(function() { + more = 1; + for (accuracy = _countdown_accuracy; accuracy >= 0 && more; accuracy --) { + value = _countdown_this.initTime[accuracy]; + if (_countdown_direction == 1) { + if (accuracy > 0 && value >= _countdown_interval[accuracy - 1] - 1) { + newValue = 0; + } + else { + newValue = value + 1; + more = 0; + } + } + else { + if (value) { + newValue = value - 1; + more = 0; + } + else if (accuracy == 0) { + countUp(); + accuracy = _countdown_accuracy + 1; + continue; + } + else { + newValue = _countdown_interval[accuracy - 1] - 1; + } + } + _countdown_this.initTime[accuracy] = newValue; + _countdown_this.objEM[accuracy].innerHTML = String(newValue); + } + }, _countdown_freq[_countdown_accuracy] * 1000); + }); } + }); + + $(document).ready(function() { + $(".block-countdown .content").onready(); + } + ); +} diff -x '*.patch' -x .svn -x CVS -urNp countdown/countdown.module countdown.new/countdown.module --- countdown/countdown.module 2007-01-15 18:34:37.000000000 -0500 +++ countdown.new/countdown.module 2007-03-07 07:43:53.343750000 -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 +?>