I this module enabled using the Bartik theme, and it won't count down - it appears to only show the exact time left from when the page loads. What could be the issue with the Javascript? I'm on D-7.12.

Comments

burt.lo’s picture

I'm new to this kind of problem. I had an issue in the 6.x version which a friend fixed by loading the js library after(?) the loading of another library.

From that, I've been trying to solve this 7.x problem by explicitly adding the js to the home page template, as in this "page--front.tpl.php" file from the 7.x Blue Masters theme... (oh, I copied the "countdown.js" file from the countdown module's directory into the theme folder, just for debugging):

<?php drupal_add_js('countdown.js'); ?>

<div id="page">

<!--header-top-->
<div id="header-top">
...

This doesn't work, but it's what I'm trying at the moment. More later.

burt.lo’s picture

Here's a patch to get this 7.x-1.0-alpha1 version working. This works on my Blue Master theme here: http://www2.ironmicrophone.com.

It addresses a couple things:

  • In the "countdown.js" file, "Drupal.jsEnabled" (line 12) has been deprecated and removed from Drupal 7, deemed superfluous, and...
  • In the "countdown.js" file, the "$(document).ready(function()" function (line 82) needs to be wrapped in a function structure to be usable. My JavaScript wizard friend (Lee Regan) could give a better explanation for this.
  • In the "countdown.tpl.php" file (lines 28, 30, 33, 36), the numeric values need to be wrapped in the <em> tags in order for the JavaScript code to locate them in the object model (within the for loops around countdown.js lines 28 to 32).

HTH.

p.s. It's my first patch... be gentle with me.

deekayen’s picture

Status: Active » Needs work

Use 2 spaces instead of tabs
Remove trailing whitespace from lines
Looks like you left a console debug line in the javascript

mahyarsbt’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)
alex.bukach’s picture

Version: 7.x-1.0-alpha1 » 8.x-1.x-dev
Category: Support request » Bug report
Status: Closed (outdated) » Needs review
StatusFileSize
new1.28 KB

I confirm the module does not work as expected, I can see that issue in both 7.x and 8.x versions. The JavaScript code expects the numbers be wrapped in 's, however they are not. Fixing it was a part of a @burt.lo's patch in #2. Here's a 8.x patch.

hannakras’s picture

Also confirming the module doesn't work as expected. I tested alex's patch (https://www.drupal.org/project/countdown/issues/1591730#comment-15756791) in a sandbox with Drupal 10.3 and branch 8.x-1.x-dev, but the only apparent change was the numbers are now displaying in italics per the tags. The timer is still not counting down dynamically, but only shows a change in countdown time when you refresh/visit the page.

alex.bukach’s picture

@hannakras I suggest you to have a look at https://www.drupal.org/project/countdown/issues/796110 and the MR there. I ended up reworking the whole module.

hannakras’s picture

Thank you, @alex.bukach. I tested your MR, and it is counting down as expected now. I will comment over in that ticket as well.

mahyarsbt’s picture

Version: 8.x-1.x-dev » 8.x-1.11
Assigned: Unassigned » mahyarsbt
Status: Needs review » Fixed
Issue tags: +JavaScript

This long-standing issue has been completely resolved in the 8.x-1.11 major refactor.

Solution implemented:

The module now features a brand new CountdownTimer library (vanilla JavaScript, ES6) with:

  • Real-time countdown mode - Live countdown with configurable precision (seconds to milliseconds)
  • Drift compensation algorithm - Maintains accuracy over extended periods
  • Zero dependencies - Pure vanilla JS, no jQuery required
  • IIFE/UMD pattern - Modern architecture compatible with Drupal 8/9/10/11
  • Auto-start capability - Begins counting immediately on page load
  • Dual-mode rendering:
    • Static mode (server-side, SEO-friendly)
    • Real-time mode (client-side, dynamic countdown)

The JavaScript now properly initializes and continuously updates the countdown display, completely eliminating the "frozen time" issue.

To enable real-time countdown:

  1. Edit your countdown block
  2. Select "Real-time JavaScript countdown" under Render Mode
  3. Configure precision (seconds recommended for most use cases)

Download 8.x-1.11: https://www.drupal.org/project/countdown/releases/8.x-1.11

Please test with the new version. If you encounter any issues, open a new issue with your specific configuration.

mahyarsbt’s picture

Status: Fixed » Closed (fixed)
Issue tags: -JavaScript +JavaScript

Fixed in: 8.x-1.11

Closing this issue as definitively fixed.

What was the problem:

The countdown displayed static time without real-time updates.

How it's fixed in 8.x-1.11:

  • New CountdownTimer library with real-time countdown
  • Drift compensation for accuracy
  • Multiple precision levels (seconds to milliseconds)
  • Lightweight vanilla JavaScript (no jQuery dependency)
  • Modern ES6 architecture (IIFE/UMD pattern)
  • Full Drupal 8/9/10/11 compatibility

Key improvements:

  • Performance: Optimized render loop with configurable update frequency
  • Accuracy: Drift compensation maintains precision over hours/days
  • Compatibility: Works with all modern browsers and Drupal versions
  • Size: ~2KB gzipped, zero external dependencies

Upgrade path:

composer update drupal/countdown
drush updatedb
drush cache:rebuild

Configuration:

Simply switch to "Real-time JavaScript countdown" in block settings to enable the dynamic countdown feature.

The architecture has been completely modernized to prevent this issue from recurring. Should you experience any problems with the new implementation, please open a new issue with:

  • Drupal version
  • Browser details
  • Block configuration export

Thank you for your patience with this long-standing issue. The wait is over - real-time countdown is here!