It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

need help editing a stopwatch script

need help editing a stopwatch script

Postby paul609 on Tue Jun 22, 2010 2:21 pm

i found a stopwatch script which is perfect except for 1 thing,

it counts and displays hours: mins: seconds: 100th seconds

like this: 00:15:17.750

ideally i would like to remove the 100th seconds from the right hand side, i have tried removing a couple of things from the code where i thought the function might be but it ended up removing the hours instead of the 100th seconds..

if anyone could point me to where i need to edit to remove the 100th seconds i would be very greatful... many thanks..

paul.
Code: Select all
   var t=[0, 0, 0, 0, 0, 0, 0, 1];

   function ss()
   {
   t[t[2]]=(new Date()).valueOf();
   t[2]=1-t[2];
   if (0==t[2])
   {
      clearInterval(t[4]);
      t[3]+=t[1]-t[0];
      t[4]=t[1]=t[0]=0;
      disp();
   }
   else
   {
      t[4]=setInterval(disp, 43);
   }
   }

   function r()
   {
   if (t[2]) ss();
   t[4]=t[3]=t[2]=t[1]=t[0]=0;
   disp();
   t[7]=1;
   }

   function disp()
   {
   if (t[2]) t[1]=(new Date()).valueOf();
   t[6].value=format(t[3]+t[1]-t[0]);
   }

   function format(ms)
   {
   var d=new Date(ms+t[5]).toString()
      .replace(/.*([0-9][0-9]:[0-9][0-9]:[0-9][0-9]).*/, '$1');
   var x=String(ms%1000);
   while (x.length<3) x='0'+x;
   d+='.'+x;
   return d;
   }

   function load()
   {
   t[5]=new Date(1970, 1, 1, 0, 0, 0, 0).valueOf();
   t[6]=document.getElementById('disp');
   disp();
   }


paul609
 
Posts: 3
Joined: Sun Jun 20, 2010 7:52 pm

Re: need help editing a stopwatch script

Postby iDad on Tue Jun 22, 2010 8:39 pm

not sure how it's done,I'm just bumping this ahead of the spam attack,I'm sure a another member has an idea for you.
good luck.
PHOTO EDITING
Image
User avatar
iDad
1000+ Club
 
Posts: 1912
Joined: Fri Jul 17, 2009 6:05 pm
Location: USA

Re: need help editing a stopwatch script

Postby paul609 on Thu Jun 24, 2010 8:34 pm

thx m8
paul609
 
Posts: 3
Joined: Sun Jun 20, 2010 7:52 pm


Who is online

Users browsing this forum: No registered users and 3 guests