Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 20th, 2004, 05:04 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,891 Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)  Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 5 Days 7 h 53 m 18 sec
Reputation Power: 1537
Useful Code Samples (javascript, ASP)

hi all, here I will post code samples I've created for my use which may be useful to you as well.

every code sample will be posted as replay in this thread, feel free to post remarks, problems or questions.

Reply With Quote
  #2  
Old October 20th, 2004, 05:14 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,891 Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)  Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338184 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 5 Days 7 h 53 m 18 sec
Reputation Power: 1537
Blinking Text

blinking text can be sometimes useful... some javascript can do the trick.

the code below currently works only for IE browser (dunno why, it's written in syntax that should be supported in Firefox - I will appreciate if someone can make it Firefox compatible as well) and enable you to define blink colors (can be more than two - simple comma seperated list) and the blink speed.
speed: lower number means faster blink. reasonable range is 20-100

also, attached the demo file.
Code:
 <html>
 <body>
 <script language="javascript">
   var arrBlinkingObjects=new Array();
   
   window.onload=function()
   {
 	 //get blinking controls:
 	 var arrDivObjects=document.getElementsByTagName("DIV");
 
 	 
 	 //look for blinking objects:
 	 for (var i=0; i<arrDivObjects.length; i++)
 	 {
 		var curAttribute=arrDivObjects[i].attributes["blink"];
 		if ((curAttribute)&&(curAttribute.nodeValue == "1"))
 		{
 		   arrBlinkingObjects[arrBlinkingObjects.length] = arrDivObjects[i];
 		   curAttribute=arrDivObjects[i].attributes["colors"];
 		   
 		   //set initial color if given:
 		   if (curAttribute)
 		   {
 			  arrDivObjects[i].style.color = curAttribute.nodeValue.split(",")[0];
 			  arrDivObjects[i].attributes.setNamedItem(MakeAttribute("activeColor", 0));
 			  arrDivObjects[i].attributes.setNamedItem(MakeAttribute("lastColorChange", CurrentMiliSeconds()));
 		   }
 		}
 	 }
 	 
 	 //activate global timer:
 	 setTimeout("BlinkTimer();", 50);
 	 
 	 //PrintTo(document, document.getElementById("DIV1"));
   }
   
   function BlinkTimer()
   {
 	 var curTime=CurrentMiliSeconds();
 	 
 	 for (var i=0; i<arrBlinkingObjects.length; i++)
 	 {
 		var curAttribute=arrBlinkingObjects[i].attributes["speed"];
 		var iSpeedRate=50;
 		if (curAttribute)
 		   iSpeedRate=(CLngDef(curAttribute.nodeValue, 5))*10;
 		var iLastChange=0;
 		curAttribute=arrBlinkingObjects[i].attributes["lastColorChange"];
 		if (curAttribute)
 		   iLastChange=CLngDef(curAttribute.nodeValue, 0);
 		//need to blink?
 		if ((iLastChange > 0)&&((curTime-iLastChange) >= iSpeedRate))
 		   SwitchColor(arrBlinkingObjects[i]);
 	 }
 	 
 	 setTimeout("BlinkTimer();", 50);
   }
   
   function SwitchColor(objDiv)
   {
 	 var iActiveColor=0;
 	 var curAttribute=objDiv.attributes["activeColor"];
 	 if (curAttribute)
 		iActiveColor=CLngDef(curAttribute.nodeValue, 0);
 	 var strBlinkColors="";
 	 var curAttribute=objDiv.attributes["colors"];
 	 if (curAttribute)
 		strBlinkColors=curAttribute.nodeValue;
 	 var arrBlinkColors=strBlinkColors.split(",");
 	 iActiveColor = ((iActiveColor+1) % arrBlinkColors.length);
 	 objDiv.style.color = arrBlinkColors[iActiveColor];
 	 objDiv.attributes["activeColor"].nodeValue = iActiveColor;
 	 objDiv.attributes["lastColorChange"].nodeValue = CurrentMiliSeconds();
   }
   
   function MakeAttribute(attName, attValue)
   {
    var objAttribute=document.createAttribute(attName);
    objAttribute.value = attValue;
    return objAttribute;
   }
   
   function CurrentMiliSeconds()
   {
    var now=new Date();
    
    return now.getTime();
   }
   
   function CLngDef(str, defValue)
   {
 	 try
 	 {
 		return (str*(-1)*(-1));
 	 }
 	 catch (e)
 	 {
 		return defValue;
 	 }
   }
   
   function PrintTo(_ob, objDiv) {
    var m="", j;
    for (j in _ob)
    {
 	  try
 	  {
 		 m += j + ": " + _ob[j] + ", ";
 	  }
 	  catch (e)
 	  {
 		 m += "error: "+j+", ";
 	  }
    
    }
    if (objDiv)
 	  objDiv.innerHTML = m;
    else
 	  alert(m);
   }
 </script>
 <div blink="1" colors="blue,red" speed="50">this text will blink if javascript is enabled</div>
 <div id="DIV1"></div>
 </body>
 </html>
 
Attached Files
File Type: zip Blink.zip (1.2 KB, 421 views)

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Useful Code Samples (javascript, ASP)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway