Skip to content

Commit 5c02b69

Browse files
committed
added restart interval/skip interval functionality
1 parent 7f0dba8 commit 5c02b69

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

app/index.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const currentIntervalText = document.getElementById("currentIntervalText");
2020
const playPauseButton = document.getElementById("playPauseButton");
2121
const playPauseIcon = playPauseButton.getElementById("combo-button-icon");
2222
const playPauseIconPressed = playPauseButton.getElementById("combo-button-icon-press");
23+
const restartSkipButton = document.getElementById("restartSkipButton");
24+
const restartSkipIcon = restartSkipButton.getElementById("combo-button-icon");
2325

2426

2527
const totalFlowInSeconds = 5; //1500;
@@ -33,6 +35,7 @@ let counting = false;
3335
let countdownSeconds = totalFlowInSeconds;
3436
let flow = true; //used to toggle between flow intervals and breaks
3537
let currentIntervalTime;
38+
let currentIntervalText;
3639
let currentSprint = 1;
3740

3841
//setup clock
@@ -53,6 +56,10 @@ playPauseButton.onactivate = (evt) => {
5356
counting ? pause() : play();
5457
}
5558

59+
restartSkipButton.onactivate = (evt) => {
60+
counting ? restart() : skip();
61+
}
62+
5663
display.onchange = () => { // optimize battery life
5764
display.on ? style() : stopStyle();
5865
}
@@ -149,18 +156,33 @@ function setupNextInterval(nextIntervalSeconds, text){
149156
currentIntervalText.text = text;
150157
//set the correct seconds for progress
151158
currentIntervalTime = countdownSeconds = nextIntervalSeconds;
159+
currentIntervalText = text;
152160
}
153161

154162
function play(){
155163
counting = true;
156164
playPauseIcon.image = "pause.png";
157165
playPauseIconPressed.image = "pause_press.png";
166+
167+
restartSkipIcon.image = "reset.png";
158168
}
159169

160170
function pause(){
161-
counting = false
171+
counting = false;
162172
playPauseIcon.image = "play.png";
163173
playPauseIconPressed.image = "play_press.png";
174+
175+
restartSkipIcon.image = "skip.png";
176+
}
177+
178+
function skip(){
179+
counting = false;
180+
nextSprint();
181+
}
182+
183+
function restart(){
184+
pause();
185+
setupNextInterval(currentIntervalTime, currentIntervalText);
164186
}
165187

166188
function formatCountdown(seconds){

resources/index.gui

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,13 @@
4949
<set href="combo-button-stroke" attributeName="display" to="inline"/>
5050
</use>
5151

52+
<use id="restartSkipButton" class="accentColor" href="#combo-button-lower-left">
53+
<set href="combo-button-icon" attributeName="href" to="skip.png"/>
54+
<set href="combo-button-icon-press" attributeName="href" to="skip_press.png"/>
55+
<set href="combo-button-stroke" attributeName="display" to="inline"/>
56+
</use>
57+
58+
59+
5260

5361
</svg>

resources/reset.png

533 Bytes
Loading

resources/skip.png

441 Bytes
Loading

resources/skip_press.png

383 Bytes
Loading

0 commit comments

Comments
 (0)