Falling Snow Background image - نوشته شده در (4554 Views)
Junior Member
NiteOwl
مطلب: 403
403
I found the following script on the net to add falling snowflakes to my forum. Can I do this with SNITZ and if so what file do I need to edit?

The following website shows this script:
http://javascript.internet.com/bgeffects/snow.html

<font color="navy"><font size="1"><SCRIPT LANGUAGE="JavaScript1.2">
<!-- Original: Altan (snow@altan.hr) -->
<!-- Web Site: http://www.altan.hr/snow -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var no = 25; // snow number
var speed = 10; // smaller number moves the snow faster
var snowflake = "http://www.your-web-site-address-here.com/snow.gif";

var ns4up = (document.layers) ? 1 : 0; // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
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; // set coordinate variables
xp[i] = Math.random()*(doc_width-50); // set position variables
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20; // set amplitude variables
stx[i] = 0.02 + Math.random()/10; // set step variables
sty[i] = 0.7 + Math.random(); // set step variables
if (ns4up) { // set layers
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></layer>");
}
} else if (ie4up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
}
}
}
function snowNS() { // Netscape main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
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()", speed);
}
function snowIE() { // IE main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
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()", speed);
}
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}
// End -->
</script</font id="size1"></font id="navy">>

<font size="1"><font color="black">< Moved to [i]MOD Add-On Forum (W/O Code)</i> by Shaggy /></font id="black"></font id="size1">
-=NiteOwl=-
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Development Team Leader
Classicmotorcycling
مطلب: 2085
2085
Would you not need to add the code to the inc_header.asp file and just after the second
Code:
<body>
tag add a
Code:
%>(JavaScript Code)<%
and it should work as long as you have their image (or one of your own) in the folder the JS points to.
I hope that helps.<
Cheers,

David Greening
نوشته شده در
New Member
Sonic
مطلب: 82
82
search in --> inc_header.asp
this line (new install on line 277)

Response.Write "</head>" & vbNewLine & _
"<body" & strTmpPageBGImageURL & " bgColor=""" & strPageBGColor & """ text=""" & strDefaultFontColor & """ link=""" & strLinkColor & """ aLink=""" & strActiveLinkColor & """ vLink=""" & strVisitedLinkColor & """>" & vbNewLine & _


edit after that it to:

Response.Write "</head>" & vbNewLine & _
"<body" & strTmpPageBGImageURL & " bgColor=""" & strPageBGColor & """ text=""" & strDefaultFontColor & """ link=""" & strLinkColor & """ aLink=""" & strActiveLinkColor & """ vLink=""" & strVisitedLinkColor & """>" & vbNewLine
if DatePart("ww", Date()) > 47 or DatePart("ww", Date()) < 10 then
Response.Write "<script language=""JavaScript1.2"" src=""snow.js"" type=""text/javascript""></SCRIPT>" & vbNewLine
end If
Response.Write "<a name=""top""></a>" & vbNewLine & _

save the script shown on your first post as --> snow.js the green part in the code: let automaticly display the "snow" on a certain time of the year. in this sample at the 48 week of the year till the 11 week of the new year. rest of time no snow is showing.
eg left in the menu of my page:


don't forget to save the javascript and save some "snow" pics :-)
<
ich finds genial... bei uns ist es ratzekuz dunkel und bei dene alle heller nachmittag smile
نوشته شده در
Junior Member
NiteOwl
مطلب: 403
403
Thanks!! this is sounding better all the time:

OK, I have saved the original code to snow.js
I have a snowflake image in my images folder called snow.gif
I have edited the original script to point to the snow graphic. I have added the new piece of code directly after the line you indicated.
However no snow is falling. :)

BTW - I ahve two instances of the code you mentioned on line 94 and line 344, I inserted your string on the 344 line.<
-=NiteOwl=-
نوشته شده در
New Member
Sonic
مطلب: 82
82
attention -->
delete in the snow.js file these lines

-- > <SCRIPT LANGUAGE="JavaScript1.2"> (first line)
and </script> (last line)

save it and it should work :-) the line 344 is ok
the path of the snowflakes must be right


--------------------------------------------------------------


if you wish to have 3 different snowflakes try this modificated code
(edit the gif path and make some images)
-->
Code:

var snowsrc="";
var snowsrc1="../img/snow/snow1.gif";
var snowsrc2="../img/snow/snow2.gif";
var snowsrc3="../img/snow/snow3.gif";

var no = 10; // change number of snow
var speed = 30; // smaller number moves the snow faster

var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;

if (ns4up||ns6up) {
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) {
snowsrc = eval("snowsrc"+RanSpan(1,3));
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) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\"><\/layer>");
}
else if (ie4up||ns6up) {
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 snowIE_NS6() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height) {
xp[i] = Math.random()*(doc_width-am[i]-10);
yp[i] = -5;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = ns6up?window.innerWidth : document.body.clientWidth;
doc_height = ns6up?window.innerHeight : document.body.clientHeight;
}
dx[i] += stx[i];
if (ie4up){
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
else if (ns6up){
document.getElementById("dot"+i).style.top = yp[i];
document.getElementById("dot"+i).style.left = xp[i] + am[i]*Math.sin(dx[i]);
}
}
setTimeout("snowIE_NS6()", speed);
}


function Random(N) {
return Math.floor(N*(Math.random()%1))
}


function RanSpan(MinV, MaxV) {
return MinV + Random(MaxV-MinV+1)
}

if (ie4up) {
snowIE_NS6();
}
<
ich finds genial... bei uns ist es ratzekuz dunkel und bei dene alle heller nachmittag smile
نوشته شده در
Junior Member
TonyB7
مطلب: 267
267
Ditto here - the flakes just sit in the upper left corner; no falling.<
نوشته شده در
Development Team Leader
Classicmotorcycling
مطلب: 2085
2085
I have no issues adding it to the forum: VN Commodore Support<
Cheers,

David Greening
نوشته شده در
Junior Member
CalloftheHauntedMaster
مطلب: 289
289
While I'm here, can someone just post the actual code snowflake code that works.<
This account was hacked into by Image, a very honest guy as you all can see! Stealing people's passwords is his pasttime. Beware of this, before you register at his forums!
نوشته شده در
New Member
Sonic
مطلب: 82
82
see above i use this code<
ich finds genial... bei uns ist es ratzekuz dunkel und bei dene alle heller nachmittag smile
نوشته شده در
Development Team Leader
Classicmotorcycling
مطلب: 2085
2085
The only thing I have done to get the demo working is changed the DatePart statement that Sonic supplied to be the following:
Code:
	Dim MyWeekday
MyWeekday = DatePart("ww", date)
if (MyWeekday > 47 and MyWeekday < 54) or (MyWeekday > 0 and MyWeekday < 10) then
Response.Write "<script language=""JavaScript1.2"" src=""snow.js"" type=""text/javascript""></script>" & vbNewLine
end If
This made it work for me with adding the original code to .js file and removing the lines as stated again by Sonic:
Code:
<SCRIPT LANGUAGE="JavaScript1.2"> (first line)
and </script> (last line)
It is running at the link I gave earlier now I have the DatePart working fine. <
Cheers,

David Greening
نوشته شده در
Junior Member
TonyB7
مطلب: 267
267
Oops. They are indeed falling in MSIE. Any idea how to make them fall in Firefox 1.5?
Under Options>Content I have both Java and Javascript enabled.<
شما باید یک متن وارد کنید