forked from tinkerhub/tink-her-hack-temp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathal.html
More file actions
261 lines (224 loc) · 8.72 KB
/
al.html
File metadata and controls
261 lines (224 loc) · 8.72 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Medicine Reminder App</title>
<style>
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #ccecf2 0%, #ccecf2 100%);
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background-color: #ffffff;
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
max-width: 400px;
width: 100%;
text-align: center;
}
h2 {
margin-bottom: 20px;
color: #333333;
}
.form-group {
margin-bottom: 20px;
}
label {
font-size: 14px;
font-weight: bold;
display: block;
margin-bottom: 8px;
color: #555;
}
input[type="date"],
input[type="time"],
input[type="number"],
select {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 8px;
font-size: 16px;
}
.checkbox-group {
display: flex;
justify-content: space-around;
margin: 10px 0;
}
.checkbox-group label {
font-size: 14px;
font-weight: normal;
}
button {
background-color: #007BFF;
color: #fff;
padding: 12px;
border: none;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
width: 100%;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
.summary {
margin-top: 20px;
padding: 15px;
background-color: #f9f9f9;
border: 1px solid #ccc;
border-radius: 8px;
}
.summary p {
margin: 5px 0;
color: #333;
}
.time-picker {
margin-top: 10px;
}
/* Hide the Next button when JavaScript is not used */
#capsule-next {
display: none;
}
</style>
</head>
<body>
<div class="container">
<h2>Medicine Reminder</h2>
<!-- Select Start Date -->
<div class="form-group">
<label for="startDate">Start Date:</label>
<input type="date" id="startDate" required>
</div>
<!-- Select End Date -->
<div class="form-group">
<label for="endDate">End Date:</label>
<input type="date" id="endDate" required>
</div>
<!-- Select Dosage Time -->
<div class="form-group">
<label>Dosage Time:</label>
<div class="checkbox-group">
<label><input type="checkbox" id="morning"> Morning</label>
<label><input type="checkbox" id="afternoon"> Afternoon</label>
<label><input type="checkbox" id="evening"> Evening</label>
</div>
</div>
<!-- Time Selection for Dosage -->
<div id="morning-time" class="time-picker" style="display: none;">
<label for="morningTime">Select Morning Time:</label>
<input type="time" id="morningTime">
</div>
<div id="afternoon-time" class="time-picker" style="display: none;">
<label for="afternoonTime">Select Afternoon Time:</label>
<input type="time" id="afternoonTime">
</div>
<div id="evening-time" class="time-picker" style="display: none;">
<label for="eveningTime">Select Evening Time:</label>
<input type="time" id="eveningTime">
</div>
<!-- Set Reminder Button -->
<button onclick="setReminder()">Set Reminder</button>
<br>
<!-- Next Button -->
<div class="form-group capsule-fields">
<a href="essinfo.html" class="btn-next" id="capsule-next">
<button>Next</button>
</a>
</div>
<!-- Reminder Summary -->
<div id="summary" class="summary" style="display: none;">
<h3>Reminder Details</h3>
<p id="summaryText"></p>
</div>
</div>
<script>
// Show the time picker based on selected dosage time
document.getElementById('morning').addEventListener('change', function() {
document.getElementById('morning-time').style.display = this.checked ? 'block' : 'none';
if (this.checked && document.getElementById('morningTime').value) {
document.getElementById('morning-time').querySelector('input').value = document.getElementById('morningTime').value;
}
});
document.getElementById('afternoon').addEventListener('change', function() {
document.getElementById('afternoon-time').style.display = this.checked ? 'block' : 'none';
if (this.checked && document.getElementById('afternoonTime').value) {
document.getElementById('afternoon-time').querySelector('input').value = document.getElementById('afternoonTime').value;
}
});
document.getElementById('evening').addEventListener('change', function() {
document.getElementById('evening-time').style.display = this.checked ? 'block' : 'none';
if (this.checked && document.getElementById('eveningTime').value) {
document.getElementById('evening-time').querySelector('input').value = document.getElementById('eveningTime').value;
}
});
// Function to play the alarm sound
function playAlarm() {
let alarmSound = new Audio('synthesized-audio_RnhveKxY.mp3');
alarmSound.play(); // Play audio
setTimeout(function() {
alert("It's time to take your medicine!"); // Show the alert after a slight delay
}, 100); // 100 ms delay, you can adjust this value
}
// Function to calculate time difference and trigger the alarm at the right time
function setReminder() {
const startDate = document.getElementById('startDate').value;
const endDate = document.getElementById('endDate').value;
const morning = document.getElementById('morning').checked;
const afternoon = document.getElementById('afternoon').checked;
const evening = document.getElementById('evening').checked;
const morningTime = document.getElementById('morningTime').value;
const afternoonTime = document.getElementById('afternoonTime').value;
const eveningTime = document.getElementById('eveningTime').value;
// Validate input fields
if (!startDate || !endDate || (!morning && !afternoon && !evening)) {
alert("Please fill all fields and select at least one dosage time.");
return;
}
let reminderTimes = [];
if (morning && morningTime) {
reminderTimes.push(`${startDate}T${morningTime}`);
}
if (afternoon && afternoonTime) {
reminderTimes.push(`${startDate}T${afternoonTime}`);
}
if (evening && eveningTime) {
reminderTimes.push(`${startDate}T${eveningTime}`);
}
// Display Summary
const summary = document.getElementById('summary');
const summaryText = document.getElementById('summaryText');
summary.style.display = "block";
summaryText.innerHTML = `
<strong>Start Date:</strong> ${startDate}<br>
<strong>End Date:</strong> ${endDate}<br>
<strong>Dosage Times:</strong> ${reminderTimes.join(', ')}
`;
alert("Reminder has been set!");
// Schedule alarms for each reminder time
reminderTimes.forEach(timeStr => {
const reminderTime = new Date(timeStr);
const currentTime = new Date();
// Calculate the difference in milliseconds
const timeDifference = reminderTime.getTime() - currentTime.getTime();
if (timeDifference > 0) {
// Schedule the alarm at the exact time
setTimeout(playAlarm, timeDifference);
}
});
// Show the "Next" button after setting the reminder
document.getElementById('capsule-next').style.display = 'inline-block';
}
</script>
</body>
</html>