comparison website/src/fschmidt/stopwatch.html @ 1287:d9b86675be24

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 27 Dec 2018 12:01:30 -0700
parents fad40fe3282d
children fb802d8aba0b
comparison
equal deleted inserted replaced
1286:9eb3a9724853 1287:d9b86675be24
31 var seconds = time % 60; 31 var seconds = time % 60;
32 time = Math.floor(time/60); 32 time = Math.floor(time/60);
33 var minutes = time % 60; 33 var minutes = time % 60;
34 time = Math.floor(time/60); 34 time = Math.floor(time/60);
35 var hours = time; 35 var hours = time;
36 seconds = ("0"+seconds).slice(-2); 36 seconds = ('0'+seconds).slice(-2);
37 minutes = ("0"+minutes).slice(-2); 37 minutes = ('0'+minutes).slice(-2);
38 time = hours + ":" + minutes + ":" + seconds; 38 time = hours + ':' + minutes + ':' + seconds;
39 document.querySelector('[time]').innerHTML = time; 39 document.querySelector('[time]').innerHTML = time;
40 } 40 }
41 41
42 function fixButtons() { 42 function fixButtons() {
43 var isRunning = localStorage.start && !localStorage.stop; 43 var isRunning = localStorage.start && !localStorage.stop;
59 function start() { 59 function start() {
60 var stop = localStorage.stop; 60 var stop = localStorage.stop;
61 if( !stop ) { 61 if( !stop ) {
62 localStorage.start = now(); 62 localStorage.start = now();
63 } else { 63 } else {
64 localStorage.removeItem("stop"); 64 localStorage.removeItem('stop');
65 localStorage.start = now() - (stop - localStorage.start); 65 localStorage.start = now() - (stop - localStorage.start);
66 } 66 }
67 fixButtons(); 67 fixButtons();
68 } 68 }
69 69
71 localStorage.stop = now(); 71 localStorage.stop = now();
72 fixButtons(); 72 fixButtons();
73 } 73 }
74 74
75 function reset() { 75 function reset() {
76 localStorage.removeItem("start"); 76 localStorage.removeItem('start');
77 localStorage.removeItem("stop"); 77 localStorage.removeItem('stop');
78 showTime(); 78 showTime();
79 fixButtons(); 79 fixButtons();
80 } 80 }
81 81
82 function loaded() { 82 function loaded() {