Little Javascript Stopwatch I Made

*EDIT: I’ll attach the .html file as the code has problems when pasted for some reason…

Comments and suggestions greatly appreciated :slight_smile:

Also here’s a version on the net: http://www.trilightdesigns.co.uk/stopwatch_in_javascript.html

-Matt

stopwatch_in_javascript.html.zip (1.29 KB)

It doesn’t work for me, when I open it in firefox and konqueror nothing happens when I press start.

Ahh, yeah, that code I pasted was something I was testing. My bad, I’ll edit and put the working code in.

working fine here, good work dude!

Thanks man :slight_smile:

I decided to scrap pasting the code into the post as it didn’t like that for some reason :S

I think I’m going to work on a timeDifference() function to give the times in between laps :slight_smile:

Also - if anyone has any suggestions on extra features for the stopwatch let me know :slight_smile:

I’d like to add some more features, make it a bit more useful (even though it’s still just a silly little app I made when bored).

i wish i can make stuff like that with ease when im bored :P; but yea, good job

Hehe thanks - once the basics were done adding simple little things to fix bugs was fun - like disabling the buttons, that stopped problems that people had when the clicked buttons when they weren’t needed :stuck_out_tongue:

PS - I’ve just validated it to xHTML Strict 1.0 - thought I may as well :slight_smile:

Just finished a new version: It now stores the lap times in an array as opposed to just displaying them on screen :slight_smile:

[code]Version history:

0.0.1 [10th June 2007]

  • Stopwatch created with start and stop functions,

0.0.2 [10th June 2007]

  • Lap and reset functions added,

0.0.3 [10th June 2007]

  • Un-needed buttons disabled,

0.1.0 [11th June 2007]

  • Stopwatch stlyed using CSS,
  • Page validated to xHTML Strict 1.0,
  • Javascript code placed into separate file,

0.1.1 [11th June 2007]

  • Lap time results placed into an array as opposed to simply displayed on page,
  • The array should allow for some manipulation,[/code]

Simple Javascript Stopwatch
.zip File including all code

If anyone has any suggestions on version number please let me know - it’s something I’ve never quite understood…

latest one looks pretty neat dude!

Thanks man, I’ve just done 0.1.2

[code]0.1.2

  • Display ‘bug’ fixed - now when seconds go from 59 → 0 it displays as: 59 → 00 → 01 instead of 59 → 0 → 01[/code]

0.1.2
Simple Javascript Stopwatch
.zip File including all code

[code]0.1.3

  • Time difference between laps added,[/code]

0.1.3
Simple Javascript Stopwatch
.zip File including all code

I’m having a few accuracy issues with the time difference - I’m going to try and recode that at somepoint - currently it uses a separate timer:

You press the lap button for the first time and it starts the timer, when you press it again, it stops the timer, grabs the results, takes 00:00:00:1 off (as it had a problem with adding it one for some reason) and puts them into variables to display on screen - it then resets the 2nd timer to 00:00:00:0 and starts this second timer again, waiting for the lap button to be pressed again.

I think I’ve found a problem - I can’t remember if I set the pause button to pause the 2nd timer and the reset button to reset the 2nd timer…