-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
196 lines (169 loc) · 5.45 KB
/
index.html
File metadata and controls
196 lines (169 loc) · 5.45 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://electronjs.org/docs/tutorial/security#csp-meta-tag -->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<title>Teme</title>
<style>
/* General */
* {
box-sizing: border-box;
}
html,
body,
#app {
height: 100%;
}
body {
margin: 0;
transition: 0.5s all;
background-color: transparent;
}
.drag-bar {
height: 20%;
margin-bottom: 2%;
max-height: 30px;
-webkit-app-region: drag;
transition: 0.5s background-color;
}
.drag-bar.visible {
background-color: #454545;
}
.container {
width: 90%;
margin: 0 auto;
}
.bg-visible {
/* background-color: #1d1d1d; */
background-color: white;
}
.bg-visible #time-input,
.bg-visible .controls button {
color: #1d1d1d;
}
#time-input {
height: 20vw;
font-size: 23vw;
width: 100%;
border: none;
color: rgb(236, 236, 236);
outline: 0;
transition: all 0.5s;
background-color: transparent;
}
.controls {
display: flex;
justify-content: space-between;
}
.controls button {
font-size: 8vw;
user-select: none;
padding: 0;
text-transform: uppercase;
color: rgb(236, 236, 236);
background-color: transparent;
border: 1px solid rgba(15, 15, 15, 0.2);
outline: none;
border: none;
}
</style>
</head>
<body>
<div id="app">
<div class="drag-bar"></div>
<div class="container">
<input class="input" type="text" id="time-input" value="00:05:00">
<div class="controls">
<button id="start-timer">Start</button>
<button id="stop-timer">Stop</button>
</div>
</div>
</div>
<script src="teme.js"></script>
<script>
var timeInput = document.getElementById('time-input');
var startTimerBtn = document.getElementById('start-timer');
var stopTimerBtn = document.getElementById('stop-timer');
var countdownLapButton = document.getElementById('lapCountdown');
var countdownClearButton = document.getElementById('clearCountdown');
var timeSetting = timeInput.value;
var temeTimerEl = document.getElementById('app');
var dragBar = document.querySelector('.drag-bar');
var mouseOut = true;
var timer1 = new Teme({
countdown: true,
interval: 1000,
callback: function () {
var current_time_ms = timer1.lap();
var current_timecode = timer1.msToTimecode(current_time_ms, false)
timeInput.value = current_timecode;
if (current_time_ms === 0) { // Time is up
timeInput.value = timer1.msToTimecode(timer1.duration_ms, false);
startTimerBtn.innerHTML = 'start';
}
}
});
// Starts the timer
startTimerBtn.addEventListener('click', function (e) {
var val = timeInput.value;
if (timer1.go) {
timer1.stop();
e.target.innerHTML = 'start';
}
else {
timer1.start(val);
e.target.innerHTML = 'pause';
}
countdown_start_time = Date.now();
});
// Stops the timer
stopTimerBtn.addEventListener('click', function (e) {
timer1.reset();
// need setTime function
timer1.start(timeSetting);
timeInput.value = timeSetting;
timer1.stop();
startTimerBtn.innerHTML = 'start';
});
timeInput.addEventListener('change', () => {
timeSetting = timeInput.value;
});
document.body.addEventListener('mouseenter', () => {
mouseOut = false;
document.body.classList.add('bg-visible');
dragBar.classList.add('visible');
});
document.body.addEventListener('mouseleave', () => {
mouseOut = true;
setTimeout(() => {
if (mouseOut) {
document.body.classList.remove('bg-visible');
dragBar.classList.remove('visible');
}
}, 3000);
});
const Store = require('./src/store.js')
const store = new Store({
configName: 'user-preferences',
defaults: {
transparent: true,
skipTaskbar: true,
alwaysOnTop: true
}
});
document.addEventListener('DOMContentLoaded', () => {
setTimerTextColor()
})
function setTimerTextColor() {
const isTransparentBg = store.get('transparent');
if (!isTransparentBg) {
timeInput.style.color = 'black';
startTimerBtn.style.color = 'black';
stopTimerBtn.style.color = 'black';
dragBar.style.backgroundColor = '#454545';
}
}
</script>
</body>
</html>