├── script.js ├── index.html ├── style.css └── style1.css /script.js: -------------------------------------------------------------------------------- 1 | var ms = 0, s = 0, m = 0, h = 0 2 | var timer; 3 | var display = document.querySelector(".timer-Display") 4 | var laps = document.querySelector(".laps") 5 | function start(){ 6 | if(!timer){ 7 | timer = setInterval(run, 10) 8 | } 9 | } 10 | 11 | function run(){ 12 | display.innerHTML = getTimer() 13 | ms++ 14 | if(ms == 100){ 15 | ms = 0 16 | s++ 17 | } 18 | if(s == 60){ 19 | s = 0 20 | m++ 21 | } 22 | if(m == 60){ 23 | m = 0 24 | h++ 25 | } 26 | 27 | if(h == 13){ 28 | h = 1 29 | } 30 | } 31 | 32 | function getTimer(){ 33 | return (h<10 ? "0" + h: h) + " : " + (m<10 ? "0" + m : m) + " : " + (s<10 ? "0" + s : s) + " : " + (ms<10 ? "0" + ms : ms); 34 | } 35 | 36 | function pause(){ 37 | stopTimer() 38 | } 39 | 40 | function stopTimer(){ 41 | clearInterval(timer) 42 | timer = false 43 | } 44 | 45 | function reset(){ 46 | stopTimer() 47 | ms = 0 48 | s = 0 49 | m = 0 50 | h = 0 51 | display.innerHTML = getTimer() 52 | } 53 | 54 | // lap = taking screenshot of current time... 55 | function lap() { 56 | if(timer) { 57 | var Li = document.createElement("li") 58 | Li.innerHTML = getTimer() 59 | laps.appendChild(Li) 60 | } 61 | } 62 | 63 | function resetLap(){ 64 | laps.innerHTML = "" 65 | } 66 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |"Until we can manage TIME, we can manage nothing else"
- Peter F. Drucker