Problème d'affichage d'une date sous Firefox (mais ok sous IE et Opera)

okita91 Messages postés 6 Date d'inscription mardi 8 septembre 2009 Statut Membre Dernière intervention 23 juillet 2014 - 16 sept. 2009 à 15:00
okita91 Messages postés 6 Date d'inscription mardi 8 septembre 2009 Statut Membre Dernière intervention 23 juillet 2014 - 24 sept. 2009 à 00:43
Bonjour,
J'essaye d'installer un compte à rebours sur un site mais alors que tout marche bien sous IE et Opera, Firefox me renvoie la valeur NaN

Exemple, pour afficher le temps écoulé depuis ce debut d'année :

<?php
  echo theme('jquery_countdown', array(
    'since' => date("F d, Y g:i a", mktime(0,0,0,0,0,2009)),
    'format' => 'YOWDHMS',
    'description' => t('Since New Year'),
  ));
?>



Et le code de ma fonction .js :


// $Id: jquery_countdown.js,v 1.1.2.4 2009/09/08 18:22:27 robloach Exp $

/**
* jQuery Countdown Drupal behavior.
*/
Drupal.behaviors.jquery_countdown = function(context) {
  // Only process if the settings exist.
  if (Drupal.settings.jquery_countdown) {
    // Loop through all the jQuery Countdown settings.
    jQuery.each(Drupal.settings.jquery_countdown, function(countdown, options) {
      // Process the date properties if available.
      if (typeof (options.until) != "undefined") {
        options.until = Drupal.jQueryCountdownProcessDate(options.until);
      }
      if (typeof (options.since) != "undefined") {
        options.since = Drupal.jQueryCountdownProcessDate(options.since);
      }

      // Evaluate the callbacks as function names.
      if (typeof (options.onExpiry) == "string") {
        options.onExpiry = eval(options.onExpiry);
      }
      if (typeof (options.onTick) == "string") {
        options.onTick = eval(options.onTick);
      }

      // Create the countdown element on non-processed elements.
      $(countdown + ':not(.jquery-countdown-processed)', context).addClass('jquery-countdown-processed').countdown(options);
    });
  }
};

/**
* Process date values for the jQuery Countdown plugin, based on the date type.
*/
Drupal.jQueryCountdownProcessDate = function(dateVal) {
  if (typeof (dateVal) == "string") {
    // Create the Date using the string.
    return new Date(dateVal);
  } else if (typeof (dateVal) == "number") {
    // Return the number of seconds.
    return dateVal;
  } else if (dateVal instanceof Array || dateVal instanceof Object) {
    // Create the Date object from available values, avoiding passing invalid
    // objects.
    var date = new Date();
    for (i = 0; i < 6; i++) {
      dateVal[i] = dateVal[i] || 0;
    }
    date.setFullYear(dateVal[0]);
    date.setMonth(dateVal[1]);
    date.setDate(dateVal[2]);
    date.setHours(dateVal[3]);
    date.setMinutes(dateVal[4]);
    date.setSeconds(dateVal[5]);
    return date;
  }
  return dateVal;
};


Si vous avez des idées pour le faire fonctionner également sous Firefox,

Merci d'avance

1 réponse

okita91 Messages postés 6 Date d'inscription mardi 8 septembre 2009 Statut Membre Dernière intervention 23 juillet 2014
24 sept. 2009 à 00:43
Petit up,
merci
0
Rejoignez-nous