aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorAdam Spiers <github@adamspiers.org>2016-04-16 16:52:34 +0100
committerAdam Spiers <github@adamspiers.org>2017-04-20 15:18:15 +0100
commita161acaba93378573237e8764e3ffa1ed62ecee1 (patch)
treef5fca0a2609a9373dd375ba32c355feee3f1ff9c /plugin
parenteb23e58114dadd6c68e41d077e32ce4959678c5a (diff)
downloadperl-software-in-gnu-guix-a161acaba93378573237e8764e3ffa1ed62ecee1.tar
perl-software-in-gnu-guix-a161acaba93378573237e8764e3ffa1ed62ecee1.tar.gz
extract time display code into new _displayTime() function
This will allow us to reuse the display code for displaying an additional pacing timer.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/notes/notes.html20
1 files changed, 12 insertions, 8 deletions
diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html
index 4fda869..2704130 100644
--- a/plugin/notes/notes.html
+++ b/plugin/notes/notes.html
@@ -463,22 +463,26 @@
minutesEl = timeEl.querySelector( '.minutes-value' ),
secondsEl = timeEl.querySelector( '.seconds-value' );
+ function _displayTime( hrEl, minEl, secEl, time) {
+ var hours = Math.floor( time / ( 1000 * 60 * 60 ) );
+ var minutes = Math.floor( ( time / ( 1000 * 60 ) ) % 60 );
+ var seconds = Math.floor( ( time / 1000 ) % 60 );
+ hrEl.innerHTML = zeroPadInteger( hours );
+ hrEl.className = hours > 0 ? '' : 'mute';
+ minEl.innerHTML = ':' + zeroPadInteger( minutes );
+ minEl.className = minutes > 0 ? '' : 'mute';
+ secEl.innerHTML = ':' + zeroPadInteger( seconds );
+ }
+
function _updateTimer() {
var diff, hours, minutes, seconds,
now = new Date();
diff = now.getTime() - start.getTime();
- hours = Math.floor( diff / ( 1000 * 60 * 60 ) );
- minutes = Math.floor( ( diff / ( 1000 * 60 ) ) % 60 );
- seconds = Math.floor( ( diff / 1000 ) % 60 );
clockEl.innerHTML = now.toLocaleTimeString( 'en-US', { hour12: true, hour: '2-digit', minute:'2-digit' } );
- hoursEl.innerHTML = zeroPadInteger( hours );
- hoursEl.className = hours > 0 ? '' : 'mute';
- minutesEl.innerHTML = ':' + zeroPadInteger( minutes );
- minutesEl.className = minutes > 0 ? '' : 'mute';
- secondsEl.innerHTML = ':' + zeroPadInteger( seconds );
+ _displayTime( hoursEl, minutesEl, secondsEl, diff );
}