Сняг (как да го оправя)

bojko91

Registered
Здравейте

Имам един код за сняг в сайта обаче полето в което вали сняг е много малко, как мога да го разширя?

Код:
var no = 10; // snow number

  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 600, doc_height = 800;
  
  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
    document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: 10"+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src=\"http://boji-dar.info/snow/dott.gif\" border=\"0\"></div>");
  }

  function snow() {
    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.getElementById("dot"+i).style.top = yp[i];
      document.getElementById("dot"+i).style.left = xp[i] + am[i]*Math.sin(dx[i]);
    }
    setTimeout("snow()", 20);
  }

  snow();

Моля ви помогнете ми.

Поздрави: Божидар
 
emagi каза:
Еми разшери DIV-a(или клетката на таблицата),в който си сложил кода!

Код:
echo"<script type='text/javascript' src='http://boji-dar.info/snow/snow.js'></script>" ;

Така съм гу пуснал в сайта (PHP - fusion)
 
emagi каза:
bojko91 каза:
Имам един код за сняг в сайта обаче полето в което вали сняг е.........

Ок незнам как да го обясня... ето виж сам как само до едно място стигат снежинките и спират по надолу не слизат :( Клик
 
emagi каза:
Я сложи този ред:
echo"<script type='text/javascript' src='http://boji-dar.info/snow/snow.js'></script>" ;
ведната след тага:
<body>
echo"<script type='text/javascript' src='http://boji-dar.info/snow/snow.js'></script>" ;
.......................
</body>

Нямам такъв таг

Код:
<?php
/*--------------------------------------------+
| PHP-Fusion v6 - Content Management System   |
|---------------------------------------------|
| author: Nick Jones (Digitanium) © 2002-2005 |
| web: http://www.php-fusion.co.uk            |
| email: nick@php-fusion.co.uk                |
|---------------------------------------------|
| Released under the terms and conditions of  |
| the GNU General Public License (Version 2)  |
+--------------------------------------------*/
/*--------------------------------------------+
|      Fusion 6 Theme for PHP-Fusion v6       |
|---------------------------------------------|
| author: PHP-Fusion Themes - Shedrock © 2005 |
| web: http://phpfusion.org                   |
| email: webmaster@phpfusion.org              |
|---------------------------------------------|
| Released under the terms and conditions of  |
| the GNU General Public License (Version 2)  |
+--------------------------------------------*/
if (!defined("IN_FUSION")) { header("Location: ../../index.php"); exit; }
require_once INCLUDES."theme_functions_include.php";

// theme settings
$body_text = "#000000";
$body_bg = "#EFEFEF";
$theme_width = "900px";
$theme_width_l = "175px";
$theme_width_r = "175px";

function render_header($header_content) {

global $theme_width,$settings;


	echo "<table style='background-image:url(".THEME."images/center.gif); margin-top: 0;' align='center' border='0' cellpadding='0' cellspacing='0' width='$theme_width'>";
	// Start banner code
	echo "<td width='100%' height='160'>$header_content</td>";
	// End banner code
	echo "<img src='".THEME."images/pixel.gif' height='5'>";
	echo "<table align='center' border='0' cellpadding='0' cellspacing='0' width='$theme_width'>";
	echo "<tr><td width='42' height='29'><img src='".THEME."images/nav_left.gif' width='42' height='29'></td>";
	echo "<td width='75%' height='29' style='background-image:url(".THEME."images/nav_center.gif)'>";
	echo showsublinks("·","white")."</td>";
	echo "<td align='right' width='25%' height='29' style='background-image:url(".THEME."images/nav_center.gif)'>";
	echo"<script type='text/javascript' src='http://boji-dar.info/snow/snow.js'></script>" ;
	echo '
	<script language="JavaScript">
		function clock() {
		now = new Date();
		hours = now.getHours();
		minutes = now.getMinutes();
		seconds = now.getSeconds();
		now_time = "" + hours;
		now_time += ((minutes < 10) ? ":0" : ":") + minutes;
		now_time += ((seconds < 10) ? ":0" : ":") + seconds;
		date = now.getDate();
		month = now.getMonth();
		switch (month) {
		case 0:
		month = "Януари";
		break;
		case 1:
		month = "Февруари";
		break;
		case 2:
		month = "Март";
		break;
		case 3:
		month = "Април";
		break;
		case 4:
		month = "Май";
		break;
		case 5:
		month = "Юни";
		break;
		case 6:
		month = "Юли";
		break;
		case 7:
		month = "Август";
		break;
		case 8:
		month = "Септември";
		break;
		case 9:
		month = "Октомври";
		break;
		case 10:
		month = "Ноември";
		break;
		case 11:
		month = "Декември";
		break;
		}
		year = now.getYear();
		den = now.getDay();
		switch (den) {
		case 0:
		den = "Неделя";
		break;
		case 1:
		den = "Понеделник";
		break;
		case 2:
		den = "Вторник";
		break;
		case 3:
		den = "Сряда";
		break;
		case 4:
		den = "Четвъртък";
		break;
		case 5:
		den = "Петък";
		break;
		case 6:
		den = "Събота";
		break;
		}
		year = now.getYear()+1900 ;
		now_date = + date + " " + month + " " + year;
		document.getElementById("clock_show").innerHTML = "<font face=Verdana size=2>" + now_date + ", " + now_time + "</font>";
		setTimeout("clock()", 1000);
		}
		</script>';
	echo "<body onLoad='clock()'><div id='clock_show'></div>";
	echo "<td width='42' height='29'><img src='".THEME."images/nav_right.gif' width='42' height='29'></td></tr></table>";
	echo "<table align='center' cellspacing='0' cellpadding='0' width='$theme_width'>\n<tr>\n";
}

function render_footer($license=false) {

global $theme_width,$locale,$settings;

	echo "</tr>\n</table>\n";
	echo "<table align='center' width='$theme_width' cellspacing='0' cellpadding='0'><tr>";
	echo "<td class='header'>".stripslashes($settings['footer'])."</td></tr></table>\n";
	echo "<table align='center' border='0' cellpadding='0' cellspacing='0' width='$theme_width'>";
	echo "<tr><td width='42' height='29'><img src='".THEME."images/nav_left.gif' width='42' height='29'></td>";
	echo "<td align='left' width='38%' height='29' style='background-image:url(".THEME."images/nav_center.gif)'>";
	if ($license == false) {
	echo "";
	}
	echo "</td>";
	echo "<td align='center' width='25%' style='background-image:url(".THEME."images/nav_center.gif)'>";
	echo "</td>";
	echo "<td align='right' width='37%' style='background-image:url(".THEME."images/nav_center.gif)'>";
	echo "<strong>".$settings['counter']." </strong>".($settings['counter'] == 1 ? $locale['140']."\n" : $locale['141']."\n");
	echo "</td>";
	echo "<td width='42'><img src='".THEME."images/nav_right.gif' width='42' height='29'></td></tr></table>";
}

function render_news($subject, $news, $info) {

global $locale;
	
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='panel-left'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "<td width='100%' class='panel-main'>$subject</td>";
	echo "<td class='panel-right'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "</tr></table>";
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='border-left'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td>";
	echo "<td class='main-body'><div style='width:100%;vertical-align:top;'>$news</div>";
	echo "<div style='margin-top:5px'>";
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='infobar'>".newsposter($info)."</td>";
	echo "<td align='right' class='infobar2'>";
	echo openform("N",$info['news_id']).newsopts($info,"·").closeform("N",$info['news_id']);
	echo "</td></tr></table></div></td>";
	echo "<td class='border-right'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'>";
	echo "</td></tr><tr>";
	echo "<td class='border-bleft'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bmain'><img src='".THEME."images/blank.gif' width='1' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bright'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "</tr></table><br>\n";
}

function render_article($subject, $article, $info) {
	
global $locale;

	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='panel-left'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "<td width='100%' class='panel-main'>$subject</td>";
	echo "<td class='panel-right'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "</tr></table>";
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='border-left'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td>";
	echo "<td class='main-body'><div style='width:100%;vertical-align:top;'>".($info['article_breaks'] == "y" ? nl2br($article) : $article)."</div>";
	echo "<div style='margin-top:5px'>";
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='infobar'>".articleposter($info)."</td>";
	echo "<td align='right' class='infobar2'>";
	echo openform("A",$info['article_id']).articleopts($info,"·").closeform("A",$info['article_id']);
	echo "</td></tr></table></div></td>";
	echo "<td class='border-right'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td>";
	echo "</tr><tr>";
	echo "<td class='border-bleft'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bmain'><img src='".THEME."images/blank.gif' width='1' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bright'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "</tr></table><br>\n";
}

function opentable($title) {

	echo "<table width='100%' cellpadding='0' cellspacing='0'>";
	echo "<tr><td class='panel-left'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "<td width='100%' class='panel-main'>$title</td>";
	echo "<td class='panel-right'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "</tr></table>";
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='border-left'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td>";
	echo "<td class='main-body'>\n";
}

function closetable() {

	echo "</td>";
	echo "<td class='border-right'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td></tr>";
	echo "<tr>";
	echo "<td class='border-bleft'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bmain'><img src='".THEME."images/blank.gif' width='1' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bright'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "</tr></table><br>\n";
}

function openside($title) {
	
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='panel-left'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "<td width='100%' class='panel-main'>$title</td>";
	echo "<td class='panel-right'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "</tr></table>";
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='border-left'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td>";
	echo "<td class='side-body'>\n";
}

function closeside() {

	echo "</td>";
	echo "<td class='border-right'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td></tr>";
	echo "<tr>";
	echo "<td class='border-bleft'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bmain'><img src='".THEME."images/blank.gif' width='1' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bright'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "</tr></table><br>\n";
}

function opensidex($title,$open="on") {

	$boxname = str_replace(" ", "", $title);
	$box_img = $open == "on" ? "off" : "on";
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='panel-left'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "<td class='panel-main'>$title</td>";
	echo "<td align='right' class='panel-main'><img src='".THEME."images/panel_$box_img.gif' name='b_$boxname' alt='' onclick="javascript:flipBox('$boxname')"></td>";
	echo "<td class='panel-right'><img src='".THEME."images/blank.gif' width='11' height='28' alt='' style='display:block'></td>";
	echo "</tr></table>";
	echo "<table width='100%' cellpadding='0' cellspacing='0'><tr>";
	echo "<td class='border-left'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td>";
	echo "<td class='side-body'>";
	echo "<div id='box_$boxname'".($open=="off" ? "style='display:none'" : "").">\n";
}

function closesidex() {

	echo "</div>";
	echo "<td class='border-right'><img src='".THEME."images/blank.gif' width='7' height='1' alt='' style='display:block'></td></tr>";
	echo "<tr>";
	echo "<td class='border-bleft'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bmain'><img src='".THEME."images/blank.gif' width='1' height='7' alt='' style='display:block'></td>";
	echo "<td class='border-bright'><img src='".THEME."images/blank.gif' width='7' height='7' alt='' style='display:block'></td>";
	echo "</tr></table><br>\n";
}

function tablebreak() {

	echo "<table width='100%' cellspacing='0' cellpadding='0'><tr><td height='5'>";
	echo "</td></tr></table>\n";
}
?>
 
НИкога не съм работил PHP-Fusion,но този файл ще се include-ва за да се ползват функциите в него!
 
bojko91 каза:
Здравейте

Имам един код за сняг в сайта обаче полето в което вали сняг е много малко, как мога да го разширя?

Код:
var no = 10; // snow number

  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 600, doc_height = 800;
  
  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
    document.write("<div id="dot"+ i +"" style="POSITION: absolute; Z-INDEX: 10"+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;"><img src="http://boji-dar.info/snow/dott.gif" border="0"></div>");
  }

  function snow() {
    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.getElementById("dot"+i).style.top = yp[i];
      document.getElementById("dot"+i).style.left = xp[i] + am[i]*Math.sin(dx[i]);
    }
    setTimeout("snow()", 20);
  }

  snow();

Моля ви помогнете ми.

Поздрави: Божидар

За да вали по целия екран го слагаш мижду body тага и ето това:
var i, doc_width = 600, doc_height = 800;

Заменяш височината и дължината със 100%
Тоест така: var i, doc_width = 100%, doc_height = 100%;


Успех!
 
сняг ли искаш??
аз имам 1 код за сняг ама снега вали до края на таблицата, но се опрява с <br> ето ти кода

Код:
<script type="text/javascript">

/******************************************
* Snow Effect Script- By Altan d.o.o. (http://www.altan.hr/snow/index.html)
* Visit Dynamic Drive DHTML code library (http://www.dynamicdrive.com/) for full source code
* Last updated Nov 9th, 05' by DD. This notice must stay intact for use
******************************************/
  
  //Configure below to change URL path to the snow image
  var snowsrc="http://tvoq_sait/snow.gif"
  // Configure below to change number of snow to render
  var no = 10;
  // Configure whether snow should disappear after x seconds (0=never):
  var hidesnowtime = 0;
  // Configure how much snow should drop down before fading ("windowheight" or "pageheight")
  var snowdistance = "pageheight";

///////////Stop Config//////////////////////////////////

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

	function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 1024, doc_height = 600; 
  
  if (ns6up) {
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
  } else if (ie4up) {
    doc_width = iecompattest().clientWidth;
    doc_height = iecompattest().clientHeight;
  }

  dx = new Array();
  xp = new Array();
  yp = new Array();
  am = new Array();
  stx = new Array();
  sty = new Array();
  snowsrc=(snowsrc.indexOf("/search/?q=сняг&qtype=images")!=-1)? "snow.gif" : snowsrc
  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 (ie4up||ns6up) {
      if (i == 0) {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\"><\/a><\/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 snowIE_NS6() {  // IE and NS6 main animation function
    doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
		doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")?  iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
    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();
      }
      dx[i] += stx[i];
      document.getElementById("dot"+i).style.top=yp[i]+"px";
      document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";  
    }
    snowtimer=setTimeout("snowIE_NS6()", 10);
  }

	function hidesnow(){
		if (window.snowtimer) clearTimeout(snowtimer)
		for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
	}
		

if (ie4up||ns6up){
    snowIE_NS6();
		if (hidesnowtime>0)
		setTimeout("hidesnow()", hidesnowtime*1000)
		}

</script>
 
bojko91 каза:
Здравейте

Имам един код за сняг в сайта обаче полето в което вали сняг е много малко, как мога да го разширя?


Моля ви помогнете ми.

Поздрави: Божидар

При мен се вижда идеално.
:)
 

Back
Горе