begin process at 2012 05 29 03:38:13
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Javascript / DHTML / Ajax

 > 

JavaScript Orienté objet (POO)

 > 

Function & Méthodes

 > 

erreur "too much recursion"


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

erreur "too much recursion"

mardi 10 octobre 2006 à 09:54:20 | erreur "too much recursion"

francois44

Bonjour à tous

J'avance petit à petit dans la création d'un système de news en objet ...  à savoir l'adaptation de la source disponible à cette adresse : http://www.javascriptfr.com/codes/NEWS-TICKER-LETTRE-LETTRE_30623.aspx (que j'ai adapté à mon besoin).

Tout marche nickel sauf l'effet effectué par le settimeout ... ma fonction d'affichage est bel et bien appelé en récursif mais j'ai l'impression qu'il n'attent pas la fin du délai pour le faire ... ce qui me donne une erreur "too much recursion" dans firefox.

voici mon code si cela inspire quelqu'un:

merci d'avance

François


Classe Comp_Info qui gère une seul info

/**
*Comp_Info
*Constructeur de la classe Comp_Info.
*
*@param     string
*@param     string
*@param     string
*@param     string
*@param     string
*@param     string
*@param     string
*
*@return     void
*/
function Comp_Info(str_Titre, str_Description, str_Lien, str_Date, str_Heure, str_Type, str_UrlImage)
{
 this.str_Titre = str_Titre;
 this.str_Description = str_Description;
 this.str_Lien = str_Lien;
 this.str_Date = str_Date;
 this.str_Heure = str_Heure;
 this.str_Type = str_Type;
 this.str_UrlImage = str_UrlImage;
}

/**
*get_Titre
*Retourne le titre.
*
*@return     string
*/
Comp_Info.prototype.get_Titre = function()
{
 return this.str_Titre;
}

/**
*get_Description
*Retourne la description.
*
*@return     string
*/
Comp_Info.prototype.get_Description = function()
{
 return this.str_Description;
}

/**
*get_Lien
*Retourne le lien.
*
*@return     string
*/
Comp_Info.prototype.get_Lien = function()
{
 return this.str_Lien;
}

/**
*get_Date
*Retourne la date.
*
*@return     string
*/
Comp_Info.prototype.get_Date = function()
{
 return this.str_Date;
}

/**
*get_Heure
*Retourne l'heure.
*
*@return     string
*/
Comp_Info.prototype.get_Heure = function()
{
 return this.str_Heure;
}

/**
*get_Type
*Retourne le type.
*
*@return     string
*/
Comp_Info.prototype.get_Type = function()
{
 return this.str_Type;
}

/**
*get_UrlImage
*Retourne l'url de l'image.
*
*@return     string
*/
Comp_Info.prototype.get_UrlImage = function()
{
 return this.str_UrlImage;
}


Classe Comp_Infos qui gère plusieurs infos


/**
*Comp_Infos
*Constructeur de la classe Comp_Infos.
*
*@return     void
*/
function Comp_Infos()
{
 this.array_Infos = new Array();
}

/**
*set_NouvelleInfo
*Ajoute une info.
*
*@param     string
*@param     string
*@param     string
*@param     string
*@param     string
*@param     string
*@param     string
*
*@return     void
*/
Comp_Infos.prototype.set_NouvelleInfo = function(str_Titre, str_Description, str_Lien, str_Date, str_Heure, str_Type, str_UrlImage)
{
 this.array_Infos[this.array_Infos.length] = new Comp_Info(str_Titre, str_Description, str_Lien, str_Date, str_Heure, str_Type, str_UrlImage);
}

/**
*check_Indice
*Vérifie la validité d'un indice.
*
*@param     integer
*
*@return     boolean
*/
Comp_Infos.prototype.check_Indice = function(int_Indice)
{
 if(this.array_Infos[int_Indice] != 'undefined')
  return true;
 else
  return false;
}

/**
*get_NbInfos
*Retourne le nombre total d'infos.
*
*@return     integer
*/
Comp_Infos.prototype.get_NbInfos = function()
{
 return this.array_Infos.length;
}

/**
*get_UnTitre
*Retourne le titre d'une info.
*
*@param     integer
*
*@return     string
*/
Comp_Infos.prototype.get_UnTitre = function(int_Indice)
{
 if(this.check_Indice(int_Indice))
  return this.array_Infos[int_Indice].get_Titre();
 else
  return 'undefined';
}

/**
*get_UneDescription
*Retourne la description d'une info.
*
*@param     integer
*
*@return     string
*/
Comp_Infos.prototype.get_UneDescription = function(int_Indice)
{
 if(this.check_Indice(int_Indice))
  return this.array_Infos[int_Indice].get_Description();
 else
  return 'undefined';
}

/**
*get_UnLien
*Retourne le lien d'une info.
*
*@param     integer
*
*@return     string
*/
Comp_Infos.prototype.get_UnLien = function(int_Indice)
{
 if(this.check_Indice(int_Indice))
  return this.array_Infos[int_Indice].get_Lien();
 else
  return 'undefined';
}

/**
*get_UneDate
*Retourne la date d'une infos.
*
*@param     integer
*
*@return     string
*/
Comp_Infos.prototype.get_UneDate = function(int_Indice)
{
 if(this.check_Indice(int_Indice))
  return this.array_Infos[int_Indice].get_Date();
 else
  return 'undefined';
}

/**
*get_UneHeure
*Retourne l'heure d'une info.
*
*@param     integer
*
*@return     string
*/
Comp_Infos.prototype.get_UneHeure = function(int_Indice)
{
 if(this.check_Indice(int_Indice))
  return this.array_Infos[int_Indice].get_Heure();
 else
  return 'undefined';
}

/**
*get_UnType
*Retourne le type d'une info.
*
*@param     integer
*
*@return     string
*/
Comp_Infos.prototype.get_UnType = function(int_Indice)
{
 if(this.check_Indice(int_Indice))
  return this.array_Infos[int_Indice].get_Type();
 else
  return 'undefined';
}

/**
*get_UneUrlImage
*Retourne l'url de l'image d'une info.
*
*@param     integer
*
*@return     string
*/
Comp_Infos.prototype.get_UneUrlImage = function(int_Indice)
{
 if(this.check_Indice(int_Indice))
  return this.array_Infos[int_Indice].get_UrlImage();
 else
  return 'undefined';
}


Classe Comp_AfficheInfos qui gère l'affichage des infos (c'est la dedans que ça bug)


/**
*comp_AfficheInfos
*Constructeur de la classe comp_AfficheInfos.
*
*@return     void
*/
function Comp_AfficheInfos(obj_CompInfos, str_IdCible, str_Prefixe, int_Vitesse, int_Attente, str_CurseurEcriture1, str_CurseurEcriture2, str_CurseurFin)
{
 this.obj_CompInfos = obj_CompInfos;
 if(document.getElementById)
  this.obj_Cible = document.getElementById(str_IdCible);
 else
  this.obj_Cible = 'undefined';
 
 this.int_IndiceInfo = 0;
 this.int_Taille = 0;
 this.str_Prefixe = str_Prefixe;
 this.int_Vitesse = int_Vitesse;
 this.int_Attente = int_Attente;
 this.str_CurseurEcriture1 = str_CurseurEcriture1;
 this.str_CurseurEcriture2 = str_CurseurEcriture2;
 this.str_CurseurFin = str_CurseurFin;
}

/**
*print_Info
*Affiche une info.
*
*@return     void
*/
Comp_AfficheInfos.prototype.print_Info = function()
{
 if(this.obj_Cible != 'undefined' && this.obj_CompInfos.get_NbInfos() > 0)
 {
  var int_TimeOut;
  
  //initialisation des données
  str_Titre = this.obj_CompInfos.get_UnTitre(this.int_IndiceInfo);
  str_Description = this.obj_CompInfos.get_UneDescription(this.int_IndiceInfo);
  str_Lien = this.obj_CompInfos.get_UnLien(this.int_IndiceInfo);
  str_Date = this.obj_CompInfos.get_UneDate(this.int_IndiceInfo);
  str_Heure = this.obj_CompInfos.get_UneHeure(this.int_IndiceInfo);
  str_Type = this.obj_CompInfos.get_UnType(this.int_IndiceInfo);
  str_UrlImage = this.obj_CompInfos.get_UneUrlImage(this.int_IndiceInfo);
  
  str_MessageInfo = str_Description + ' [' + str_Date + ' ' + str_Heure + ']';
  str_Curseur = this.get_Curseur(str_MessageInfo.length);
  str_Info = str_Titre + ' : ' + str_MessageInfo.substring(0, this.int_Taille) + str_Curseur;
  
  //affiche l'info
  longueurCible = this.obj_Cible.firstChild.length;
  this.obj_Cible.firstChild.replaceData(0, longueurCible, str_Info);
  
  
  
  // Modifie la taille de la chaine ainsi que le timer
  if(this.int_Taille != str_Info.length)
  {
   this.int_Taille++;
   int_TimeOut = this.int_Vitesse;
  }
  else
  {
   this.int_IndiceInfo++;
   if(this.int_IndiceInfo >= this.obj_CompInfos.get_NbInfos())
    this.int_IndiceInfo = 0;
   this.int_Taille = 0;
   int_TimeOut = this.int_Attente;
  }
  
  //appelle en récursif de la fonction
  var Obj = this;
  setTimeout(Obj.print_Info(), int_TimeOut);  //le problème doit venir de quelque part par la ...
 }
}

/**
*get_Curseur
*Retourne le curseur actif.
*
*@return     string
*/
Comp_AfficheInfos.prototype.get_Curseur = function(int_Taille)
{
 if(this.int_Taille == int_Taille)
  return this.str_CurseurFin;

 if((this.int_Taille % 2) == 1)
  return this.str_CurseurEcriture1;
 else
  return this.str_CurseurEcriture2;
}

mardi 10 octobre 2006 à 10:57:03 | Re : erreur "too much recursion"

francois44

Si ça peut aidé, voilà comment on s'en sert:

var obj_CompInfos = new Comp_Infos();
obj_CompInfos.set_NouvelleInfo('Mon Titre', 'Ma description', 'Mon lien', '09/10/06', '12:00', 'Mon Type', 'Mon image');
obj_CompInfos.set_NouvelleInfo('Mon Titre2', 'Ma description2', 'Mon lien2', '09/10/05', '12:00', 'Mon Type2', 'Mon image deux');
obj_CompInfos.set_NouvelleInfo('Mon Titre3', 'Ma description : trois', 'Mon lien3', '09/12/06', '12:56', 'Mon Type trois', 'Mon image 3');

var obj_AfficheInfos = new Comp_AfficheInfos(obj_CompInfos, 'tickerAnchor', 'INFOS : ', 50, 5000, '-', '>', '');
obj_AfficheInfos.print_Info();

mardi 10 octobre 2006 à 10:59:37 | Re : erreur "too much recursion"

francois44

Il faut bien sur avoir une balise nommé "tickerAnchor" dans le document ...

du genre:
<div id="tickerAnchor">
</div>


Cette discussion est classée dans : int, str, return, get, indice


Répondre à ce message

Sujets en rapport avec ce message

Récupérer valeur post ou get [ par Flyer ] Comment je peut faire pour récuprer les valeurs des variables transmisent à une autre page par l'intermédiaire d'un post ou un get ?Ex:Page 1 envoie à obtenir l'URL d'une frame par une autre [ par SoniqExnihilo ] Voila. j'ai un framse contenant 2 frame. Dans la premiere frame il y as 2 boutons,un Get et un Set, et une zone de text, dans la seconde il y a google date [ par natnat ] bonjor,je suis en stage et ds une panade complete, si qq'1 pouvait m'aider, ce serait super coolje passe à suivre la fonction que j'ai copié et adapté aidez-moi [ par paradoxreal8 ] ParadoxReal8au secours J'ai faait une source pour u "-1" [ par eryk17 ] dans ce code :function isEmail(elm){if (elm.value.indexOf("@") != "-1" && elm.value.indexOf(".") != "-1" ){ return true;} else { return false;}} Creation de fonctino (explode [ par Isabella ] Bonjour à tous, J'essaye d'integrer une fonction explode au script "Liste avec recherche par clavier" (Cf http://www.toutjavascript.com/main/) Je sépa Y a un problême. [ par sschupp ] Date function verif() { res = false res2 = true if (this.form.annee1 > this.form.annee2) return res; if (window.document.f appel de fonction avec return [ par sylcasi ] bonjour,je veux appeler sur un seul evenement plusieurs fonctions, dont la première avec un return.problème : quelque soit la valeur de return (false verification formulaire avec test() [ par ygsi5355 ] J'avais une vérification qui fonctionnait bien.J'ai ajouté || (/^[0-9] {10}$/.test(document.quizz.tel.value))pour vérifier qu'il y a uniquement 10 chi help [ par Danila ] bonjour voici mon formulaire :formulaire{if (document.form1.nom.value == "") {alert("Veuillez saisir votre nom")return false


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,733 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales