-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcircle.html
181 lines (164 loc) · 5.71 KB
/
circle.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Circular Progress Bar with Clock</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
margin: 0;
}
.container {
position: relative;
width: 200px;
height: 200px;
}
.progress-bar {
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
/* transform: rotate(-90deg); */
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}
.progress-bar::before {
content: '';
position: absolute;
width: 80%;
height: 80%;
border-radius: 50%;
background-color: #f0f0f0;
top: 10%;
left: 10%;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
.clock {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
font-family: Arial, sans-serif;
color: #333;
}
.slider-container {
margin-top: 20px;
text-align: center;
}
.slider {
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<div class="progress-bar" id="progressBar"></div>
<div class="clock" id="clock">00:00:00</div>
</div>
<div class="slider-container">
<input type="range" min="0" max="36" value="0" class="slider" id="slider">
</div>
<script>
const SAMPLE_BLOCKS = [
{
title: "Absorptive Phase",
color: "#2196f3",
offsetHours: 0,
durationHours: 4
},
{
title: "Early Fasting Phase",
color: "#4caf50",
offsetHours: 4,
durationHours: 4
},
{
title: "Glycogen Depletion",
color: "#ff9800",
offsetHours: 8,
durationHours: 4
},
{
title: "Ketone Production",
color: "#f44336",
offsetHours: 12,
durationHours: 4
},
{
title: "Autophagy Activation",
color: "#9c27b0",
offsetHours: 16,
durationHours: 2
},
{
title: "Increased Fat Breakdown",
color: "#673ab7",
offsetHours: 18,
durationHours: 6
},
{
title: "Deepened Ketosis",
color: "#3f51b5",
offsetHours: 24,
durationHours: 6
},
{
title: "Enhanced Insulin Sensitivity",
color: "#00bcd4",
offsetHours: 30,
durationHours: 6
}
];
const progressBar = document.getElementById('progressBar');
const clock = document.getElementById('clock');
const slider = document.getElementById('slider');
function updateClock() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
clock.textContent = `${hours}:${minutes}:${seconds}`;
}
function updateProgressBar() {
const value = slider.value;
const degrees = (value / 72) * 360;
let gradient = `conic-gradient(`;
let currentDegree = 0;
SAMPLE_BLOCKS.forEach(block => {
const blockStart = (block.offsetHours / 72) * 720;
const blockEnd = blockStart + ((block.durationHours / 72) * 720);
if (value < block.offsetHours) {
// Slider hasn't reached this block yet
return;
} else if (value < block.offsetHours + block.durationHours) {
// Slider is within this block
const blockProgress = value - block.offsetHours;
const blockDegreeProgress = (blockProgress / 72) * 360 * (block.durationHours / block.durationHours);
gradient += `${block.color} ${currentDegree}deg ${blockStart + blockDegreeProgress}deg,`;
currentDegree = blockStart + blockDegreeProgress;
} else {
// Slider has passed this block
gradient += `${block.color} ${currentDegree}deg ${blockEnd}deg,`;
currentDegree = blockEnd;
}
});
// Fill remaining degrees with lightgray up to current degree
gradient += `lightgray ${currentDegree}deg ${degrees}deg,`;
// Fill beyond current degree with transparent
gradient += `transparent ${degrees}deg 720deg)`;
progressBar.style.background = gradient;
}
slider.addEventListener('input', updateProgressBar);
setInterval(updateClock, 1000);
updateClock();
updateProgressBar();
</script>
</body>
</html>