-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminimal.html
More file actions
182 lines (171 loc) · 7.33 KB
/
minimal.html
File metadata and controls
182 lines (171 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="timer | spaghet">
<meta property="og:site_name" content="timer">
<meta property="og:locale" content="en_US">
<meta property="og:url" content="https://timer.spaghet.me">
<meta name="twitter:site" content="https://timer.spaghet.me">
<meta data-hid="title" name="title" content="timer | spaghet">
<meta data-hid="description" name="description" content="A simple count down timer.">
<meta property="og:type" content="website">
<meta property="og:title" content="timer | spaghet">
<meta property="og:description" content="A simple count down timer.">
<meta property="og:image" content="assets/Logo.png">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="timer | spaghet">
<meta name="twitter:description" content="A simple count down timer.">
<meta name="twitter:image" content="assets/Logo.png">
<meta name="twitter:image:alt" content="Timer logo">
<title>timer | spaghet</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
<link rel="stylesheet" href="style.css">
<link rel="icon" href="assets/Logo.svg" type="image/x-icon">
<!-- Manifest File link -->
<meta name="apple-mobile-web-app-status-bar" content="yellow">
<meta name="theme-color" content="yellow">
<link rel="manifest" href="manifest.json">
</head>
<body>
<div id="app">
<div v-if="isTimerActive" class="overlay" :style="`height: ${((timerMeta.duration - timerMeta.timeLeft) / timerMeta.duration) * 100
}%;`">
<div class="time" v-if="timerMeta.prettyTime">{{timerMeta.prettyTime}}</div>
<div class="minimal-time-end" v-if="timerMeta.prettyEndTime">Timer Ends at <code>{{timerMeta.prettyEndTime.toLocaleTimeString()}}</code></div>
<div class="minimal-actions" v-if="isTimerEnded">
<button class="danger" style="background-color: red;" @click="cancel()">STOP</button>
<button class="cancel" @click="repeatTimer()">REPEAT</button>
</div>
<div class="minimal-actions" v-else>
<button @click="playPause()">{{timerStateText}}</button>
<button class="cancel" @click="cancel()">CANCEL</button>
</div>
</div>
<nav v-if="!isTimerActive">
<h1 @click="window.navigation.navigate('/')">timer</h1>
<a @click="allowSound = !allowSound" class="sound-indicator" title="Toggle if you want sound to play.">
<img src="assets/volume-up-solid.svg" alt="Sound Playing indicator" v-if="allowSound">
<img src="assets/volume-mute-solid.svg" alt="Sound Playing indicator" v-else>
</a>
</nav>
<div class="timer-form" v-if="!isTimerActive">
<h3>{{activeForm}}</h3>
<div class="inputs">
<input type="number" ref="hours" name="Hours" id="Hours" placeholder="hh" v-model="form.hours" @focus="activeForm = 'HOURS'" @input="formatMaxLength('hours', 2)" maxlength="2" min="0" max="24">
<input type="number" ref="minutes" name="Minutes" id="Minutes" placeholder="mm" v-model="form.minutes" @focus="activeForm = 'MINUTES'" @input="formatMaxLength('minutes', 3)" maxlength="3" min="0" max="120">
<input type="number" ref="seconds" name="Seconds" id="Seconds" placeholder="ss" v-model="form.seconds" @focus="activeForm = 'SECONDS'" @input="formatMaxLength('seconds', 3)" maxlength="3" min="0" max="180">
</div>
<button @click="createTimer()" :disabled="!isFormValid">START</button>
<div class="end-time" v-if="formEndTime">Timer ends at <code>{{formEndTime}}</code></div>
</div>
<div class="quick-timers" v-if="!isTimerActive">
<button @click="quickTimer(0,0,30);">30 Seconds</button>
<button @click="quickTimer(0,1,0);">1 Minute</button>
<button @click="quickTimer(0,3,0);">3 Minutes</button>
<button @click="quickTimer(0,5,0);">5 Minutes</button>
<button @click="quickTimer(0,10,0);">10 Minutes</button>
<button @click="quickTimer(0,15,0);">15 Minutes</button>
<button @click="quickTimer(0,30,0);">30 Minutes</button>
<button @click="quickTimer(1,0,0);">1 Hour</button>
</div>
<audio src="assets/alarm.mp3" ref="audio"></audio>
</div>
<footer>
Made by <a href="https://spaghet.me">tony</a>
</footer>
<script src="minimal.js">
/*
TODO:
- Styling
- make it look pretty
- favicon
- notification icon
- branding
- colors
- sex
- deploy
- gh pages, Domains add new sub domain for timer.spaghet.me
- theming
- persistence
- Allow users to refresh and keep their timers.
- Keep track of users past timers.
Done:
- Notifications
- Handle timer end.
- Play / Pause functionality
- Alerting ^ - Sounds and stuff or something.
- add music or some shit
*/
</script>
<script type="module">
window.onload = () => {
if (Notification.permission !== "denied" && Notification.permission !== 'granted') {
Notification.requestPermission().then(function (permission) {
console.log('%cThank you for allowing notifications.', 'font-size: 20px;background: blue; color: white;');
});
}
}
window.addEventListener('load', () => {
registerSW();
});
// Register the Service Worker
async function registerSW() {
if ('serviceWorker' in navigator) {
try {
await navigator
.serviceWorker
.register(new URL('serviceworker.js', import.meta.url));
}
catch (e) {
console.log('SW registration failed');
}
}
}
</script>
<style>
.overlay {
background: black;
position: absolute;
bottom: 0;
left: 0;
height: 100%;
max-height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 0.5rem;
transition: height 0.15s linear;
}
.overlay .time {
color: white;
font-family: monospace;
font-weight: bold;
font-size: 2rem;
}
.overlay .minimal-actions {
display: flex;
}
.overlay .minimal-actions button {
background: none;
font-family: monospace;
color: white;
}
.overlay .minimal-actions .danger {
background: none!important;
color: red;
}
.overlay .minimal-actions button:hover {
color: yellow;
cursor: pointer;
}
.overlay .minimal-time-end {
color: white;
font-family: monospace;
}
</style>
</body>
</html>