Author |
Topic |
wasssup1990
Nobel Prize Winner
A Land Down Under
2261 Posts |
Posted - Aug 17 2009 : 08:57:18 AM
|
Hello!
I have done heaps of reasearch and experimenting and still no luck. How on earth do I create 'new' function instances in JavaScript? |
When one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion. |
|
codingplanet
Mad Scientist
United Kingdom
195 Posts |
Posted - Aug 17 2009 : 11:16:55 AM
|
Maybe if you explained a little of what you are trying to do, then I could help :) |
|
|
wasssup1990
Nobel Prize Winner
A Land Down Under
2261 Posts |
Posted - Aug 17 2009 : 10:39:48 PM
|
Instead of creating a new function for every glowing cell on my webpage, I want to just have one function in my javascript file that can be used as a template to make any color parameter glow on my webpage.
For example:
JavaScript var TimerCellColor=0x6c; var CopyrightCellColor=0x6c; var t; var t2; function TimerMouseOver(state,internalCall) { if (internalCall == 'no') ExternalCallState = state;
if (ExternalCallState == 'over'){ if (TimerCellColor < 0xff) TimerCellColor+=10;} else{ if (TimerCellColor > 0x6c) TimerCellColor-=10;} if (TimerCellColor < 256) document.getElementById('TimerCell').style.backgroundColor="#"+TimerCellColor.toString(16)+"C0EE"; clearTimeout(t); t=setTimeout("TimerMouseOver(ExternalCallState,'yes')",1); }
function CopyrightMouseOver(state,internalCall) { if (internalCall == 'no') ExternalCallState2 = state;
if (ExternalCallState2 == 'over'){ if (CopyrightCellColor < 0xff) CopyrightCellColor+=10;} else{ if (CopyrightCellColor > 0x6c) CopyrightCellColor-=10;} if (CopyrightCellColor < 256) document.getElementById('CopyrightCell').style.backgroundColor="#"+CopyrightCellColor.toString(16)+"C0EE"; clearTimeout(t2); t2=setTimeout("CopyrightMouseOver(ExternalCallState2,'yes')",1); }
HTML CODE
<table width="100%" height="37" border="1">
<tr>
<td width="247" height="31" align="center" valign="top" nowrap="nowrap" scope="col" id="CopyrightCell" onmouseover="CopyrightMouseOver('over','no')" onmouseout="CopyrightMouseOver('out','no')">© 2009 Cyberdyne Systems <br />
(<a href="../webmaster.html" title="Cyberdyne Systems: Webmaster" id="webmaster_link">Webmaster</a>)
</th>
<td width="854" scope="col">
</th>
<td width="293" align="center" nowrap="nowrap" id="TimerCell" scope="col" onmouseover="TimerMouseOver('over','no')" onmouseout="TimerMouseOver('out','no')">Time spent on page:
<label id=TimeDisplay>Try firefox?</label>
</th>
</tr>
</table>
The two functions in the JavaScript handle the glowing background of a table cell. The table cells are defined in the HTML code of id="TimerCell" and id=CopyrightCell. Just to re-state, I want to be able to have only one function in my javascript and create 'new' instances (like in C language) so that I can easily set many color parameters of my HTML code to glow on my webpage.
I hope I made myself clear enough.
P.S. http://cyberdyne.vndv.com/
|
When one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion. |
Edited by - wasssup1990 on Aug 17 2009 10:41:22 PM |
|
|
codingplanet
Mad Scientist
United Kingdom
195 Posts |
Posted - Aug 18 2009 : 06:51:11 AM
|
You could try something like this:
function CellMouseOver(cellname,state,internalCall) { if (internalCall == 'no') ExternalCallState2 = state;
if (ExternalCallState2 == 'over'){ if (tCellColor < 0xff) CellColor+=10;} else{ if (CellColor > 0x6c) CellColor-=10;}
if (CellColor < 256) document.getElementById(cellname).style.backgroundColor="#"+CellColor.toString(16)+"C0EE"; clearTimeout(t2); t2=setTimeout("CellMouseOver(cellname,ExternalCallState2,'yes')",1); }
Passing the cell name to the subroutine. Because the routine will only be called once at a time (cursor can't be in two places at once), you shouldn't need to use call "new" on the routine. I'm not sure I caught all occurrences of the cell name, there may also be some other changes to be made but hopefully that will give you a start. |
|
|
wasssup1990
Nobel Prize Winner
A Land Down Under
2261 Posts |
Posted - Aug 18 2009 : 07:07:27 AM
|
I'll give it a try. Thanks for your effort to help me. |
When one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion. |
|
|
codingplanet
Mad Scientist
United Kingdom
195 Posts |
Posted - Aug 18 2009 : 12:20:17 PM
|
No problem. If you need any more assistance, I'll be waiting. |
|
|
wasssup1990
Nobel Prize Winner
A Land Down Under
2261 Posts |
Posted - Aug 21 2009 : 05:47:04 AM
|
Okay I am slowly building up my website. BTW, the link has changed.
http://cyberdyne.x10hosting.com/ |
When one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion. |
Edited by - wasssup1990 on Aug 21 2009 05:47:27 AM |
|
|
codingplanet
Mad Scientist
United Kingdom
195 Posts |
Posted - Aug 21 2009 : 07:20:11 AM
|
Not sure I like the "Cyberdyne Systems" text flashing at me all the time though. Apart from that it's looking great :) |
|
|
wasssup1990
Nobel Prize Winner
A Land Down Under
2261 Posts |
Posted - Aug 21 2009 : 09:28:29 AM
|
Yeah, I don't like that much either. I'm going to 'design' my heading and have it slightly animated but not like it currently is. Something that is more easier and pleasant for the eyes. I'll probably use photoshop, solidworks or illustrator to design the heading. I think the color scheme works, and it suits a technical website.
Thanks for your input buddy. |
When one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion. |
|
|
wasssup1990
Nobel Prize Winner
A Land Down Under
2261 Posts |
Posted - Aug 25 2009 : 05:12:49 AM
|
What about now?
http://cyberdyne.x10hosting.com/
I still haven't designed my own heading but it looks good they way it is for now. Maybe the header background is to vibrant? |
When one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion. |
|
|
codingplanet
Mad Scientist
United Kingdom
195 Posts |
Posted - Aug 25 2009 : 11:24:59 AM
|
Yes, that's rather pleasing. Although I don't enjoy things glowing at me either while I'm trying to read things. Can't you just leave the background colour of the title static? |
|
|
wasssup1990
Nobel Prize Winner
A Land Down Under
2261 Posts |
Posted - Aug 25 2009 : 12:56:03 PM
|
Yes I no what you mean. I'll keep the heading the way it is until I can design a better looking one. Maybe a smooth, extruded metallic surface with a periodic glinting light sweeping across it. A little bit of animattion in the header shouldn't cause too much visual interferance since the stuff that people will be reading will be below the header. |
When one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion. |
|
|
codingplanet
Mad Scientist
United Kingdom
195 Posts |
Posted - Aug 25 2009 : 3:47:51 PM
|
Sounds good to me. Looking forward to seeing it :) |
|
|
wasssup1990
Nobel Prize Winner
A Land Down Under
2261 Posts |
Posted - Aug 27 2009 : 10:39:30 AM
|
I have made a few more improvements. The heading is still not changed.
http://cyberdyne.x10hosting.com/ |
When one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion. |
Edited by - wasssup1990 on Aug 27 2009 10:40:02 AM |
|
|
Aaron Cake
Administrator
Canada
6718 Posts |
Posted - Aug 29 2009 : 10:34:30 AM
|
Looks good. For some reason my CPU useage jumps to 75% as long as the page is open, though. |
|
|
codingplanet
Mad Scientist
United Kingdom
195 Posts |
Posted - Aug 29 2009 : 1:07:08 PM
|
I don't have that problem. I tried both IE & FF. |
|
|
Topic |
|