94 lines
2.2 KiB
HTML
94 lines
2.2 KiB
HTML
|
<html>
|
|||
|
<head>
|
|||
|
<script type="text/javascript" src="jquery-1.4.4.js"></script>
|
|||
|
<title>Sapin de No<4E>l</title>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<p>Ce script necessite jQuery pour fonctionner !</p>
|
|||
|
<table class="sapin_noel" style="border-spacing: 0px;
|
|||
|
text-align: center;
|
|||
|
margin: 0;
|
|||
|
padding: 0;
|
|||
|
line-height:0.25em;
|
|||
|
font-size: 1em;
|
|||
|
color: #008000;" "></table>
|
|||
|
<table class="sapin_noel" style="border-spacing: 0px;
|
|||
|
text-align: center;
|
|||
|
margin: 0;
|
|||
|
padding: 0;
|
|||
|
line-height:0.5em;
|
|||
|
font-size: 2em;
|
|||
|
color: #008000;" "></table>
|
|||
|
<script type="text/javascript">
|
|||
|
|
|||
|
//fonction de g<>n<EFBFBD>ration de sapin
|
|||
|
function gen_sapin_noel(h_def,prob_ball){
|
|||
|
|
|||
|
//constantes vous pouvez les modifier et admirer !!! enjoy
|
|||
|
//var h_def = 10;
|
|||
|
//var prob_ball = 40;
|
|||
|
|
|||
|
//code g<>n<EFBFBD>ration du sapin
|
|||
|
var sapin_de_noel = "";
|
|||
|
var nbr_balls = 0;
|
|||
|
for(var i=0 ; i < h_def ; i++){
|
|||
|
var nbr_stars = (i*2)-1 ;
|
|||
|
var stars = "";
|
|||
|
for(var j=0 ; j < nbr_stars ; j++)
|
|||
|
{
|
|||
|
|
|||
|
//ecriture du code pour ajouter les boules LOL
|
|||
|
if(Math.round(Math.random()*51) > prob_ball){
|
|||
|
nbr_balls++;
|
|||
|
stars += "<span class=\"balln"+ nbr_balls +"\">●</span>";
|
|||
|
}
|
|||
|
else{
|
|||
|
stars += "*";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
sapin_de_noel += "<TR><TD>"+stars+"</TD></TR>";
|
|||
|
|
|||
|
}
|
|||
|
//pied de sapin
|
|||
|
var pied= "";
|
|||
|
for(var j=0 ; j < Math.round(((h_def*2)-1)*0.25) ; j++){
|
|||
|
pied += "*";
|
|||
|
}
|
|||
|
for(var i=0 ; i < Math.round(h_def*0.30) ; i++){
|
|||
|
sapin_de_noel += "<TR><TD style=\"color: #993300;\">"+pied+"</TD></TR>";
|
|||
|
}
|
|||
|
|
|||
|
ar_sapin_de_noel = [sapin_de_noel, nbr_balls] ;
|
|||
|
|
|||
|
return ar_sapin_de_noel;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//main
|
|||
|
//Cr<43>er les sapins
|
|||
|
//Selectionne tous les <table class="sapin_noel">
|
|||
|
var i = 0;
|
|||
|
var max_balls = 0;
|
|||
|
while($(".sapin_noel")[i] != null){
|
|||
|
var sapin_gen = gen_sapin_noel(10,40);
|
|||
|
$(".sapin_noel")[i].innerHTML = sapin_gen[0];//je pense que c'est d<>gueulasse de l'<27>crire comme <20>a ...(innerHTML pour un table) je suis un Newbe en javascript
|
|||
|
if(sapin_gen[1] > max_balls) max_balls = sapin_gen[1] ;
|
|||
|
i++;
|
|||
|
}
|
|||
|
|
|||
|
//fonction pour animer !
|
|||
|
function sapin_anim(){
|
|||
|
for(var i=1 ; i != max_balls+1 ; i++){
|
|||
|
//def une couleur al<61>atoire
|
|||
|
$(".balln"+i).css("color" , '#'+Math.floor(Math.random()*16777215).toString(16));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//animation du sapin
|
|||
|
sapin_anim();
|
|||
|
var timer=setInterval("sapin_anim()", 500);
|
|||
|
|
|||
|
</script>
|
|||
|
</body>
|
|||
|
</html>
|