-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
134 lines (128 loc) · 6.04 KB
/
index.html
File metadata and controls
134 lines (128 loc) · 6.04 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
<!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">
<nav>
<h1>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" v-if="isTimerActive">
<div class="time" v-if="timerMeta.prettyTime">{{timerMeta.prettyTime}}</div>
<div class="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="actions" v-else>
<button @click="playPause()">{{timerStateText}}</button>
<button class="cancel" @click="cancel()">CANCEL</button>
</div>
<div class="end-time" v-if="timerMeta.prettyEndTime">Timer Ends at <code>{{timerMeta.prettyEndTime.toLocaleTimeString()}}</code></div>
</div>
<div class="timer-form" v-else>
<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> | <a href="/minimal">minimal</a>
</footer>
<script src="script.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>
</body>
</html>