Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what does the script of a counter or clock look like? 1

Status
Not open for further replies.

gabrielwert

Programmer
Jul 3, 2008
10
0
0
BR
I want to modify a javascript counter from an aplication,
but the .js file is so big I can`t find what is the code of a counter or clock ( not a real clock ) it`s just a counter to count seconds. it`s hard for me since javascript is new for me. what does the script of a counter or clock look like?
 
Usually it involves a setTimeout() function calling certain function, y() say, itself where the setTimeout() resides. If it is counting every second, the 2nd parameter of the setTimeout() would be 1000 (milliseconds).
[tt]
function y() {
//do something
setTimeout("y()",1000)
//do something, such as adjusting some global variable
}[/tt]
 
I think it`s this:

if( self != top ){
setTimeout('fb_boyWalk(); ',1000);
setTimeout('fb_setPoints("012345");',2000);

would the script below be a global variable?

*/

function fb_padLeft(Str,Length,PadChar){
Str +="";
Length =parseInt(0+Length,10);
PadChar +="";
if(PadChar.length==0) PadChar=" ";
var Count=0;
var PadLength =Length-Str.length;
for(Count=0; Count<PadLength; Count++) Str=PadChar+Str;
return(Str);
}
 
>would the script below be a global variable?
No, it is not in multiple sense. It is a function which I _commonly_ would not even call it (global) variable without qualification. Second, the function fb_padLeft() itself seems not setting any global variable. But, you know, my previous comment is just figurative. Concretely implementation can take many twists.
 
This is the other part that I forgot to copy!

}
function fb_setPoints(s){
fb_points.innerHTML=fb_padLeft(s,6,"0");
}
function fb_setReferrals(s){
fb_referrals.innerHTML=fb_padLeft(s,5,"0");
}

now, what does the whole script look like?
thanks for the help!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top