I miss you a merry christmas ... c'est bien mais c'est long

Contenu du snippet

C'est un code qui permet de savoir le nombre de jours avant Noël et aussi vous pouvez changez la couleur de l'arrière-plan

Source / Exemple :


<div align="center">
<h2>Sélectionner un mois</h2>
<FORM NAME="calControl" onSubmit="return false;">
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
<TR><TD COLSPAN=7>
<CENTER>
<SELECT NAME="month" onChange="selectDate()">
<OPTION>Janvier
<OPTION>Février
<OPTION>Mars
<OPTION>Avril
<OPTION>Mai
<OPTION>Juin
<OPTION>Juillet
<OPTION>Août
<OPTION>Septembre
<OPTION>Octobre
<OPTION>Novembre
<OPTION>Décembre
</SELECT>
<INPUT NAME="year" TYPE=TEXT SIZE=4 MAXLENGTH=4>
<INPUT TYPE="button" NAME="Go" value="Batir!" onClick="selectDate()">
</CENTER>
</TD>
</TR>
<TR><TD align="center"><textarea FONT="Courier" NAME="calPage" WRAP=no ROWS=8 COLS=22></textarea></TD><TR><TD><CENTER>
<INPUT TYPE=BUTTON NAME="previousYear" VALUE=" <<  "    onClick="setPreviousYear()">
<INPUT TYPE=BUTTON NAME="previousYear" VALUE="  <  "    onClick="setPreviousMonth()">
<INPUT TYPE=BUTTON NAME="previousYear" VALUE="Aujourd'hui"    onClick="setToday()">
<INPUT TYPE=BUTTON NAME="previousYear" VALUE="  >  "    onClick="setNextMonth()">
<INPUT TYPE=BUTTON NAME="previousYear" VALUE="  >> "    onClick="setNextYear()">
</CENTER></TD></TR>
</TABLE></FORM>
</DIV><script language="JavaScript">
      <!-- Begin
      // This script and many more are available free online at
      // The JavaScript Source!! http://javascript.internet.com
      // Original:  Rob Patrick (rpatrick@mit.edu)
      var now,day,month,year,days;
      function setToday() {
      now   = new Date();
      day   = now.getDate();
      month = now.getMonth();
      year  = now.getYear();
      if (year < 2000)        // Y2K Fix, Isaac Powell
      year = year + 1900;     // http://onyx.idbsu.edu/~ipowell
      this.focusDay = day;
      document.calControl.month.selectedIndex = month;
      document.calControl.year.value = year;
      displayCalendar(month, year);
      }
      function isFourDigitYear(year) {
      if (year.length != 4) {
      alert ("Sorry, the year must be four-digits in length.");
      document.calControl.year.select();
      document.calControl.year.focus();
      } else { return true; }
      }
      function selectDate() {
      year  = document.calControl.year.value;
      if (isFourDigitYear(year)) {
      day   = 0;
      month = document.calControl.month.selectedIndex;
      displayCalendar(month, year);
          }
      }
      
      function setPreviousYear() {
      year  = document.calControl.year.value;
      if (isFourDigitYear(year)) {
      day   = 0;
      month = document.calControl.month.selectedIndex;
      year--;
      document.calControl.year.value = year;
      displayCalendar(month, year);
         }
      }
      function setPreviousMonth() {
      year  = document.calControl.year.value;
      if (isFourDigitYear(year)) {
      day = 0;
      month = document.calControl.month.selectedIndex;
      if (month == 0) {
      month = 11;
      if (year > 1000) {
      year--;
      document.calControl.year.value = year;
      }
      } else { month--; }
      document.calControl.month.selectedIndex = month;
      displayCalendar(month, year);
         }
      }
      function setNextMonth() {
      year  = document.calControl.year.value;
      if (isFourDigitYear(year)) {
      day   = 0;
      month = document.calControl.month.selectedIndex;
      if (month == 11) {
      month = 0;
      year++;
      document.calControl.year.value = year;
      } else { month++; }
      document.calControl.month.selectedIndex = month;
      displayCalendar(month, year);
         }
      }
      function setNextYear() {
      year = document.calControl.year.value;
      if (isFourDigitYear(year)) {
      day = 0;
      month = document.calControl.month.selectedIndex;
      year++;
      document.calControl.year.value = year;
      displayCalendar(month, year);
         }
      }
      function displayCalendar(month, year) {
      month = parseInt(month);
      year = parseInt(year);
      var i = 0;
      days = getDaysInMonth(month+1,year);
      var firstOfMonth = new Date (year, month, 1);
      var startingPos = firstOfMonth.getDay();
      days += startingPos;
      document.calControl.calPage.value  =   " Di Lu Ma Me Je Ve Sa";
      document.calControl.calPage.value += "\n --------------------";
      for (i = 0; i < startingPos; i++) {
      if ( i%7 == 0 ) document.calControl.calPage.value += "\n ";
      document.calControl.calPage.value += "   ";
      }
      for (i = startingPos; i < days; i++) {
      if ( i%7 == 0 ) document.calControl.calPage.value += "\n ";
      if (i-startingPos+1 < 10)
      document.calControl.calPage.value += "0";
      document.calControl.calPage.value += i-startingPos+1;
      document.calControl.calPage.value += " ";
      }
      for (i=days; i<42; i++)  {
      if ( i%7 == 0 ) document.calControl.calPage.value += "\n ";
      document.calControl.calPage.value += "   ";
      }
      document.calControl.Go.focus();
      }
      function getDaysInMonth(month,year)  {
      days;
      if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)  days=31;
      else if (month==4 || month==6 || month==9 || month==11) days=30;
      else if (month==2)  {
      if (isLeapYear(year)) { days=29; }
      else { days=28; }
      }
      return (days);
      }
      function isLeapYear (Year) {
      if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
      return (true);
      } else { return (false); }
      }
      // End -->
      </script>	
	  <!-- JavaScript Couper-coller de ISN Toolbox
   Copyright 1996, Infohiway Server Network.  L'utilisation restreinte
   est accordée (pour un usage personnel ou commercial en autant que le
   code de programmation n'est pas vendu directement). De plus, cet avis
   doit être présent dans un endroit quelconque de votre document HTML. 
   Un hyperlien vers  http://www.infohiway.com sera toujours apprécié, 
   mais n'est nullement nécessaire. ;-)   -->
   <div align="center">
   
   <script language="JavaScript">
   <!-- Begin
   // fixes a Netscape 2 and 3 bug
   function mygetFullYear(d) { // d is a date object
    yr = d.getYear();
    if (yr < 1000)
     yr+=1900;
    return yr;
   }
   function getRemaining() {
    today = new Date();
    targetdate = new Date("December 25, "+mygetFullYear(today)); 
    milliseconds = (24 * 60 * 60 * 1000);
    remaining = ((targetdate.getTime() - today.getTime()) / milliseconds); 
    return Math.round(remaining);
   }
   document.write("<TABLE BORDER=3 cellpadding=5><TR><TD ALIGN=CENTER><BR>"
    + "<FONT SIZE='5' COLOR='red'><B>Seulement un aide mémoire . . .<P>"
    + "<B>Il y a seulement ",getRemaining()," jours de shopping <P>restant "
    + "avant NOEL!</B></FONT><P></TD></TR></TABLE><P>");
   // End -->
   </script>
   </div>		
   <center>
   <form name=f>
   <table border=1>
   <tr>
   <td colspan=3 align=center bgcolor="#ff0000">ROUGE</td>
   <td colspan=3 align=center bgcolor="#00ff00">VERT</td>
   <td colspan=3 align=center bgcolor="#000ff">BLEU</td>
   </tr>
   <tr>
   <td><input type=button name=rm value="<" onclick = "color(this.form, 'Red' , -1);"></td>
   <td><input type=button name=Red value="AF" onclick = "setval(this, this.form);"></td>
   <td><input type=button name=rp value=">" onclick = "color(this.form, 'Red', 1);"></td>
   <td><input type=button name=gm value="<" onclick = "color(this.form, 'Green', -1);"></td>
   <td><input type=button name=Green value="BF" onclick = "setval(this, this.form);"></td>
   <td><input type=button name=gp value=">" onclick = "color(this.form, 'Green', 1);"></td>
   <td><input type=button name=bm value="<" onclick = "color(this.form, 'Blue', -1);"></td>
   <td><input type=button name=Blue value="CF" onclick = "setval(this, this.form);"></td>
   <td><input type=button name=bp value=">" onclick = "color(this.form, 'Blue', 1);"></td>
   </tr>
   </table>
   </form>
   </center>
   <!-- auteur:  Dion (yobo42@hotmail.com) -->
   <!-- Site Web:  http://yoboseyo42.virtualave.net -->
   <!-- Ce script et plusieurs autres sont disponibles sur le site -->
   <!-- The JavaScript Source! http://javascript.internet.com -->
   
   <SCRIPT LANGUAGE="JavaScript">
   
   <!-- Begin
   function color(frm, clr, val) {
   v = eval("0x" + frm[clr].value) + val;
   if (v < 0 || v > 255) v -= val;
   v = v.toString(16).toUpperCase();
   while (v.length < 2) v = "0" + v;
   frm[clr].value = v; nc = "";
   for(i = 1; i < 8; i += 3) nc += frm.elements[i].value;
   document.bgColor = nc;
   }
   function setval(myitem) {
   v = prompt("Nouvelle valeur pour " + myitem.name + " (00 - FF)", myitem.value);
   if (v) {
   decv = eval("0x" + v);
   if ((decv & 255) == decv) {
   myitem.value=decv.toString(16).toUpperCase();
   while (myitem.value.length < 2) myitem.value = "0" + myitem.value;
         }
      }
   nc = "#";
   for(i = 1; i < 8; i += 3) nc += frm.elements[i].value;
   document.bgColor = nc;
   }
   //  End -->
   </script>  
   <script language="JavaScript">
   <!-- Begin
   // Original:  Kurt Grigg (kurt.grigg@virgin.net))
   // Web Site:  http://website.lineone.net/~kurt.grigg/javascript
   // This script and many more are available free online at
   // The JavaScript Source!! http://javascript.internet.com
   
   function nMouse(evnt){
   Ypos = evnt.pageY;
   Xpos = evnt.pageX;
   }
   function iMouse() {
   Ypos = event.y+document.body.scrollTop;
   Xpos = event.x+document.body.scrollLeft;
   }
   ns = (document.layers)?1:0;
   Clrs = new Array('ff0000','00ff00','ffffff','ff00ff','ffa500','ffff00','00ff00','ffffff','ff00ff');
   yBase = 0;
   xBase = 0;
   step = 3;
   currStep = 0;
   Ypos = 0;
   Xpos = 0;
   if (ns){
   for (i = 0; i < 14; i++)
   document.write('<LAYER NAME="n'+i+'" LEFT=0 TOP=0 CLIP="0,0,'+i/4+','+i/4+'"></LAYER>');
   window.captureEvents(Event.MOUSEMOVE);  
   window.onMouseMove = nMouse;
   }
   else{
   document.write('<div style="position:absolute;top:0;left:0"><div style="position:relative">');
   for (i=0; i < 14; i++)
   {document.write('<div id="me" style="position:absolute;top:0;left:0;width:'+i/4+';height:'+i/4+';font-size:'+i/4+'"></div>');}
   document.write('</div></div>');
   document.onmousemove = iMouse;
   }
   function Comet() {
   var yBase = (document.layers)?window.innerHeight/4:window.document.body.clientHeight/4;
   var xBase = (document.layers)?window.innerWidth/4:window.document.body.clientWidth/4;
   for (i = 0; i < 14; i++){
   var randCol = Math.round(Math.random()*8);
   var layer = (document.layers)?document.layers['n'+i]:me[i].style;
   layer.top =Ypos + yBase*Math.cos((currStep+i*4)/12)*Math.cos(0.7+currStep/200);
   layer.left = Xpos + xBase*Math.sin((currStep+i*3)/10)*Math.sin(8.2+currStep/400);
   if (ns) layer.bgColor = Clrs[randCol];
   else
   layer.background = Clrs[randCol];
   }
   currStep += step;
   setTimeout("Comet()",10);
   }
   window.onload = Comet;
   //  End -->
   </script> 
   <div align="center">
   <form>
   <input type="button" onClick="shake(2)" value="Vibrer l'écran">
   </form>
   </div><script language="JavaScript1.2">
         <!-- Begin
         // This script and many more are available free online at
         // The JavaScript Source!! http://javascript.internet.com
         
         function shake(n) {
         if (parent.moveBy) {
         for (i = 10; i > 0; i--) {
         for (j = n; j > 0; j--) {
         parent.moveBy(0,i);
         parent.moveBy(i,0);
         parent.moveBy(0,-i);
         parent.moveBy(-i,0);
                  }
               }
            }
         }
         // End -->
         </script>	  
		 <span id="liveclock" style="position:absolute;left:0;top:0;">
   </span>
   
   <script language="JavaScript">
   <!-- Begin
   
   /*
    Script Horloge en temps réel dans le coin supérieur gauche -
   © Dynamic Drive (www.dynamicdrive.com)
   Pour le code source complet, les instructions d'installation,
   des centaines d'autres scripts DHTML et les modalités d'utilisation,
   visitez dynamicdrive.com

  • /
function show5(){ if (!document.layers&&!document.all) return; var Digital=new Date(); var hours=Digital.getHours(); var minutes=Digital.getMinutes(); var seconds=Digital.getSeconds(); var dn="AM"; if (hours>12){ dn="PM"; hours=hours-12; } if (hours==0) hours=12; if (minutes<=9) minutes="0"+minutes; if (seconds<=9) seconds="0"+seconds; //modifiez ici la taille de la police, si désiré myclock="<font size='5' face='Arial' ><b><font size='1'>Heure:</font></br>"+hours+":"+minutes+":" +seconds+" "+dn+"</b></font>"; if (document.layers){ document.layers.liveclock.document.write(myclock); document.layers.liveclock.document.close(); } else if (document.all) liveclock.innerHTML=myclock; setTimeout("show5()",1000); } // End --> </script>

Conclusion :


Je sais pas ce que je vais faire peut-être des améloriations ...

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.

Du même auteur (cs_maquisard)