Skip to content

Commit 89b0164

Browse files
committed
web: timer: several fixes, including blinking for the last minute
1 parent f551189 commit 89b0164

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

web/annunciators.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<td><button class="indicator" id="chat">Chat</button></td>
4949
<td><button class="indicator" id="slower">Slower</button></td>
5050
<td><button class="indicator" id="faster">Faster</button></td>
51-
<td><input size="4" id="A" class="timer" style="text-align: center" title="Timer. Set the duration with formats MM[:SS][/DD] (time remaining) or @HH:MM[/DD] (end time), where DD is planned duration in minutes. It starts changing color 75% of the way through."></span></td>
51+
<td><input size="4" id="A" class="timer" style="text-align: center" title="Timer. Set the duration with formats MM[:SS][/DD] (time remaining) or @[HH:]MM[/DD] (end time), where DD is planned duration in minutes. It starts changing color 75% of the way through."></span></td>
5252
</tr>
5353
</table>
5454

web/control.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,14 +719,23 @@ async function init_timers() {
719719
//console.log(event)
720720
input = event.target
721721

722-
regex_at = /@(\d\d?):(\d\d?)(\/(\d+))?/
722+
regex_at = /@((\d\d?):)?(\d\d?)(\/(\d+))?/
723723
match_at = input.value.match(regex_at)
724724
if (match_at) {
725725
// Match format @HH:MM/DD where HH:MM is a real time and DD is duration in minutes
726726
endtime = new Date()
727-
endtime.setHours(parseInt(match_at[1]))
728-
endtime.setMinutes(parseInt(match_at[2]))
729-
duration = match_at[4]*60 || null
727+
hours = match_at[2] || null
728+
minutes = match_at[3]
729+
if (hours === null) {
730+
if (minutes <= endtime.getMinutes()) {
731+
hours = endtime.getHours() + 1
732+
} else {
733+
hours = endtime.getHours()
734+
}
735+
}
736+
endtime.setHours(hours)
737+
endtime.setMinutes(minutes)
738+
duration = match_at[5]*60 || null
730739
endtime = Math.round(endtime.getTime()/1000)
731740
console.log('timer parse (end time)', match_at, endtime, duration)
732741
} else {
@@ -764,6 +773,7 @@ async function timer_set(id, endtime, duration) {
764773
console.log('timer_set', id, endtime)
765774
// Start a countdown timer
766775
input = document.querySelector('input#'+id)
776+
input.style.backgroundColor = null
767777
// token is a way to tell when a new timer has been set. If token is different, stop ticking.
768778
input.token = Math.random()
769779
setTimeout(timer_tick, 500, id, endtime, duration, input.token)
@@ -790,7 +800,10 @@ async function timer_tick(id, endtime, duration, token) {
790800
fraction_remaining = remaining / duration
791801
if (fraction_remaining < .75) {
792802
fraction = fraction_remaining * 4 // 1 when started, 0 when out
793-
input.style.backgroundColor = `hsl(288, 100%, ${Math.max(50+50*fraction)}%)`
803+
if (remaining % 2 == 0)
804+
input.style.backgroundColor = `hsl(288, 100%, ${Math.max(50+50*fraction)}%)`
805+
else
806+
input.style.backgroundColor = null
794807
}
795808
} else {
796809
console.log(`timer ${id} is focused`)

web/director.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<td><button class="indicator" id="slower">Slower</button></td>
5151
<td><button class="indicator" id="faster">Faster</button></td>
5252
<td><span class="time" title="Current time"></span></td>
53-
<td><input size="6" id="A" class="timer" style="text-align: center" title="Timer. Set the duration with formats MM[:SS][/DD] (time remaining) or @HH:MM[/DD] (end time), where DD is planned duration in minutes. It starts changing color 75% of the way through."></span></td>
53+
<td><input size="6" id="A" class="timer" style="text-align: center" title="Timer. Set the duration with formats MM[:SS][/DD] (time remaining) or @[HH:]MM[/DD] (end time), where DD is planned duration in minutes. It starts changing color 75% of the way through."></span></td>
5454
</tr>
5555
</table>
5656

web/small.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<td><span class="synced" syncwith="scene">Scene</span></td>
5858
<td><span class="time" title="Current time"></span></td>
5959
<td class="playfile timer" title="Timer for ongoing playback">-</td>
60-
<td><input size="4" id="A" class="timer" style="text-align: center" title="Timer. Set the duration with formats MM[:SS][/DD] (time remaining) or @HH:MM[/DD] (end time), where DD is planned duration in minutes. It starts changing color 75% of the way through."></span></td>
60+
<td><input size="4" id="A" class="timer" style="text-align: center" title="Timer. Set the duration with formats MM[:SS][/DD] (time remaining) or @[HH:]MM[/DD] (end time), where DD is planned duration in minutes. It starts changing color 75% of the way through."></span></td>
6161
<td class="status">Status</td>
6262
</tr>
6363
</table>

web/tablet.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<button class="indicator" id="chat">Chat</button>
5858
<button class="indicator" id="slower">Slower</button>
5959
<button class="indicator" id="faster">Faster</button>
60-
<input size="6" id="A" class="timer" style="text-align: center" title="Timer. Set the duration with formats MM[:SS][/DD] (time remaining) or @HH:MM[/DD] (end time), where DD is planned duration in minutes. It starts changing color 75% of the way through.">
60+
<input size="6" id="A" class="timer" style="text-align: center" title="Timer. Set the duration with formats MM[:SS][/DD] (time remaining) or @[HH:]MM[/DD] (end time), where DD is planned duration in minutes. It starts changing color 75% of the way through.">
6161
</div>
6262
<div style="display: grid; grid-template-columns: 1fr 2fr 2fr 1fr"> <!-- under indicators-->
6363
<div style="display:grid;"> <!-- first column-->

0 commit comments

Comments
 (0)