Partage
  • Partager sur Facebook
  • Partager sur Twitter

Compte à rebours inversé

A partir d'une date.

    19 avril 2011 à 17:13:47

    Bonjour à tous,

    CowBoySD m'avait créé ce compteur javascript / html :
    ==> http://darkevin.webatu.com/compteurallemand.html

    Je n'arrive pas à le joindre et j'aimerai, en modifiant le code, que à partir d'une date, les jours s'ajoute du style :
    Le voyage en Allemagne, c'était il y a 14 jours, 22 minutes, 30 secondes etc...

    Voici le code :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
    <head>
        <title>Voyage en Allemagne</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link rel="icon" type="image/x-icon" href="http://darkevin.webatu.com/favico.png" />
        <link rel="stylesheet" media="screen" type="text/css" title="Design" href="design.css" />
    </head>
    <body onload="start()">
    
    <br />
    <div id="TextFR">Chargement ...</div>
    
    <br />
    <br />
    <div id="TextAL">Laden ...</div>
    
    <script type="text/javascript">
    	var AfficheFR = document.getElementById("TextFR");
    	var AfficheAL = document.getElementById("TextAL");
    	function compte_a_rebour() {
    		var date_actuelle = new Date();
    		var date_evenement = new Date("Apr 07 07:00:00 2011");
    		var secondes = (date_evenement - date_actuelle) / 1000;
    		if(secondes > 0){
    			DiffJour = Math.floor (secondes / 86400);
    			DiffHeure = Math.floor ((secondes - (DiffJour * 86400)) / 3600);
    			DiffMin = Math.floor ((secondes - ((DiffJour * 86400 + DiffHeure * 3600))) / 60);
    			DiffSec = Math.floor (secondes - ((DiffJour * 86400 + DiffHeure * 3600 + DiffMin * 60)));
    			var EtFR = "et";
    			var EtAL = "und";
    			if(DiffJour == 0){
    				DiffJour = '';
    				JourFR = '';
    				JourAL = '';
    			} else {
    				JourFR = (DiffJour == 1) ? "jour," : "jours,";
    				JourAL = (DiffJour == 1) ? "Tage," : "Tagen,";
    			}
    			if(DiffHeure == 0){
    				DiffHeure = '';
    				HeureFR = '';
    				HeureAL = '';
    			} else {
    				HeureFR = (DiffHeure == 1) ? "heure," : "heures,";
    				HeureAL = (DiffHeure == 1) ? "Stunde," : "Stunden,";
    			}
    			if(DiffMin == 0){
    				DiffMin = '';
    				MinuteFR = '';
    				MinuteAL = '';
    			} else {
    				MinuteFR = (DiffMin == 1) ? "minute" : "minutes";
    				MinuteAL = (DiffMin == 1) ? "Minute" : "Minuten";
    			}
    			if(DiffSec == 0){
    				DiffSec = '';
    				SecondeFR = '';
    				SecondeAL = '';
    				EtFR = '';
    				EtAL = '';
    			} else {
    				SecondeFR = (DiffSec == 1) ? "seconde" : "secondes";
    				SecondeAL = (DiffSec == 1) ? "Sekunde" : "Sekunden";
    				EtFR = (DiffMin == 0 && DiffHeure == 0 && DiffJour == 0) ? "" : "et";
    				EtAL = (DiffMin == 0 && DiffHeure == 0 && DiffJour == 0) ? "" : "und";
    			}
    			AfficheFR.innerHTML = '<span style="background:black; color:white;font-weight:bold;padding:5px;">Le départ en allemagne, c\'est dans ' + DiffJour + ' ' + JourFR + ' ' + DiffHeure + ' ' + HeureFR + ' ' + DiffMin + ' ' + MinuteFR + ' ' + EtFR + ' ' + DiffSec + ' ' + SecondeFR + '</span> &nbsp; &nbsp; <img src="http://darkevin.webatu.com/verryhappy.png">';
    			AfficheAL.innerHTML = '<span style="background:black; color:white;font-weight:bold;padding:5px">Die Abfahrt nach Deutschland ist in ' + DiffJour + ' ' + JourAL + ' ' + DiffHeure + ' ' + HeureAL + ' ' + DiffMin + ' ' + MinuteAL + ' ' + EtAL + ' ' + DiffSec + ' ' + SecondeAL + '</span> &nbsp; &nbsp; <img src="http://darkevin.webatu.com/verryhappy.png">';
    		} else {
    			AfficheFR.innerHTML = '<span style="background:black; color:white;font-weight:bold;padding:5px;">Nous sommes chez vous !</span> &nbsp; &nbsp; <img src="http://darkevin.webatu.com/hein.gif">';
    			AfficheAL.innerHTML = '<span style="background:black; color:white;font-weight:bold;padding:5px">Wir sind bei euch !</span> &nbsp; &nbsp; <img src="http://darkevin.webatu.com/hein.gif">';
    		}
    		Time_ReLance = setTimeout("compte_a_rebour();", 1000);
    	}
    	function start(){
    		Time_Lance = setTimeout("compte_a_rebour();", 750);
    	}
    </script>
    </body>
    </html>
    


    Merci à vous ;)
    • Partager sur Facebook
    • Partager sur Twitter
      19 avril 2011 à 23:40:44

      Je ne vois quelles modifications tu as tentées d'apporter par toi-même ?
      • Partager sur Facebook
      • Partager sur Twitter

      Compte à rebours inversé

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
      • Editeur
      • Markdown