Сняг - дата.бг

kitchenbg

Registered
добре де, имам такова въпросче ........... как става този номер със снега който вали във дата.бг?
 
http://www.web-tourist.net/forum/viewtopic.php?t=199


1
snwflk1.gif

2
snwflk2.gif

3
snwflk3.gif

4
snwflk4.gif


DEMO : http://web-tourist.net/project/staf/demo80.html

Слагате това в body <script SRC='snow.js'></script>
И създавате следният файл:

snow.js

В него само променяте Картинка 1,2,3,4 и слагате вашите снежинки
Код:
function rnd(){return Math.random();}
function xRnd(){return (rnd()/10);}
function yRnd(){return (2+2*(.5-rnd()));}
var letitsnow=true;
var flakes=Array("Картинка 1","Картинка 2","Картинка 3","Картинка 4");
var numflakes=5;
var GheosTime=50;
var Gheosdx,GheosxPos,GheosyPos,vx,vy,GheosObj,iVar;
var winwidth=640;
var winheight=480;

function sizeIt(){
window.winwidth=window.innerWidth?window.innerWidth:document.body.clientWidth;
window.winheight=window.innerHeight?window.innerHeight:document.body.clientHeight;
}

Gheosdx=new Array();
GheosxPos=new Array();
GheosyPos=new Array();
sway=new Array();
var swaymax=20;
vx=new Array();
vy=new Array();
sizeIt();
document.write('<STYLE TYPE="text/css">\n.flk {position:absolute;top:-100;}<\/STYLE>');
for(iVar=0;iVar<numflakes;iVar++){
	var thisflake=''+flakes[Math.floor(rnd()*flakes.length)];
	Gheosdx[iVar]=0;
	
	GheosxPos[iVar]=rnd()*(window.winwidth-30)+10;
	GheosyPos[iVar]=rnd()*window.winheight;
	sway[iVar]=rnd()*swaymax;
	vx[iVar]=xRnd();
	vy[iVar]=yRnd();
	document.write('<DIV ID="f'+iVar+'" CLASS="flk"><IMG SRC="'+thisflake+'" BORDER="0"><\/DIV>');
}

function snowMove(id,left,top){
	GheosObj=document.getElementById?document.getElementById(id).style:
	document.all?document.all[id].style:
	document.layers?document.layers[id]:null;
	if(GheosObj){
		GheosObj.left=left;
		GheosObj.top=top;
	}
}

function snowSwitch(s){
	if(s=='on'){
		if(window.letitsnow!=true){	
			window.letitsnow=true;
			doSnow();
		}
	} else if(s=='off'){
		window.letitsnow=false;
		hideSnow();
	}
}

function hideSnow(){
for(jVar=0;jVar<numflakes;++jVar)snowMove('f'+jVar,-100,-100);
}

function doSnow(){
if(letitsnow){
	sizeIt();
	delta=(window.pageYOffset!=null)?window.pageYOffset:document.body.scrollTop;
	for(kVar=0;kVar<numflakes;++kVar){
		GheosyPos[kVar]+=vy[kVar];
		if(GheosyPos[kVar]>window.winheight+delta-20){
			GheosxPos[kVar]=rnd()*(window.winwidth-sway[kVar]-30);
			GheosyPos[kVar]=delta;
			vx[kVar]=xRnd();
			vy[kVar]=yRnd();
		}
		Gheosdx[kVar]+=vx[kVar];
		snowMove('f'+kVar,GheosxPos[kVar]+sway[kVar]*Math.cos(Gheosdx[kVar]),GheosyPos[kVar]);
	}
	setTimeout("doSnow()",GheosTime);
  }	
}
//setTimeout("sunshine()",30000);
function sunshine(){
snowSwitch('off');return false;
}
window.onload=doSnow;
setTimeout("doSnow()",500);
 
Слагаш това м/у <body> и </body>
Код:
<script language="JavaScript1.2">
var snowsrc="http://im.data.bg/images/snow/snwflk1.gif" ;
var no = 10;
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0; i < no; ++ i) {  
dx[i] = 0;
xp[i] = Math.random()*(doc_width-50);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\"></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\"></layer>");
}
} else if (ie4up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"></div>");
}
}
}
function snowNS() { 
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowNS()", 10);
}
function snowIE() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowIE()", 20);
}
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}
</script>

staf тъкмо да го постна и ти го даде :-)

ДЕМО
 
съжалявам, но тъй ако може да ми помогнете и със това как да го вмъкна и във форума ................ :(
 
kitchenbg каза:
съжалявам, но тъй ако може да ми помогнете и със това как да го вмъкна и във форума ................ :(

за да го вмъкнеш и във форум просто слагаш скрипта във templates\tvoq template\overall_header.tpl
 

Back
Горе