-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
221 lines (189 loc) · 8.34 KB
/
index.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./assets/style.css">
<title>Reminder</title>
</head>
<body>
<nav >
<ul class="sidebar">
<li onclick=hideSideBar()><a href="#"><svg xmlns="http://www.w3.org/2000/svg" height="28px" viewBox="0 -960 960 960" width="28px" fill="#5f6368"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Tasks</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Login</a></li>
</ul>
</nav>
<nav>
<ul>
<li><a href="#" >Pic4ty</a></li>
<li class="hideOnMobile"><a href="#" >Blog</a></li>
<li class="hideOnMobile"><a href="#" >Tasks</a></li>
<li class="hideOnMobile"><a href="#" >Contact</a></li>
<li class="hideOnMobile"><a href="#" >About</a></li>
<li class="hideOnMobile"><a href="#" >Login</a></li>
<li onclick=showSideBar() id="menuBar"><a href="#" ><svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="32px" fill="#5f6368"><path d="M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z"/></svg></a></li>
</ul>
</nav>
<div class="container">
<h3 style="text-align: center; padding: auto;">REMINDER APPLICATION</h3>
<div>
<form id="reminderForm" action="">
<label for="title">Title:</label>
<input type="text" id="title">
<label for="description">Description:</label>
<input type="text" id="description">
<label for="date">Date:</label>
<input type="date" id="date">
<label for="time">Time:</label>
<input type="time" id="time">
<button type="submit">Schedule Reminder</button>
<table border="1">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Date & Time</th>
<th>Action</th>
</tr>
</thead>
<tbody id="reminderTableBody"></tbody>
</table>
</form>
</div>
<audio src="./assets/mixkit-clear-announce-tones-2861.wav" id="notificationSound"></audio>
</div>
<script>
if ('Notification' in window) {
Notification.requestPermission().then(function (permission) {
if (Notification.permission !== 'granted') {
alert("Please allow notification access!")
location.reload()
}
})
}
var timeoutIds = []
document.getElementById('reminderForm').addEventListener('submit', function (event) {
event.preventDefault();
scheduleReminder();
});
function scheduleReminder() {
var title = document.getElementById("title").value;
var description = document.getElementById('description').value;
var time = document.getElementById('time').value;
var date = document.getElementById('date').value;
var dateTimeString = date + " " + time;
var scheduledTime = new Date(dateTimeString);
var currentTime = new Date();
var timeDifference = scheduledTime - currentTime;
if (timeDifference > 0) {
addReminder(title, description, dateTimeString);
var timeoutId = setTimeout(function () {
document.getElementById("notificationSound").play();
var notification = new Notification(title, {
body: description,
requireInteraction: true,
});
}, timeDifference);
timeoutIds.push(timeoutId);
} else {
alert("The scheduled time is in the past!");
}
}
function addReminder(title, description, dateTimeString) {
var tablebody = document.getElementById("reminderTableBody");
var row = tablebody.insertRow();
var titleCell = row.insertCell(0);
var descriptionCell = row.insertCell(1);
var dateTimeCell = row.insertCell(2);
var actionCell = row.insertCell(3);
titleCell.innerHTML = title;
descriptionCell.innerHTML = description;
dateTimeCell.innerHTML = dateTimeString;
actionCell.innerHTML = `<button onclick="deleteReminder(this);">Delete</button>`;
}
function deleteReminder(button) {
var row = button.parentNode.parentNode;
row.parentNode.removeChild(row);
}
</script>
<!-- <div class="container">
<h3 style="text-align: center; padding: auto;">REMINDER APPLICATION</h3>
<div>
<form action="">
<label for="">Title:</label>
<input type="text" id="title">
<label for="">Description :</label>
<input type="text" id="description">
<label for="">Date :</label>
<input type="date" id="date">
<label for="">Time :</label>
<input type="time" id="time">
<button id="schedule" onclick="scheduleReminder()">Schedule Reminder</button>
<table border="1">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Date & Time</th>
<th>Action</th>
</tr>
</thead>
<tbody id="reminderTableBody"></tbody>
</table>
</form>
</div>
<audio src="./assets/mixkit-clear-announce-tones-2861.wav" id="notificationSound"></audio>
</div>
<script src="main.js"></script>
<script>
if('Notification' in window){
Notification.requestPermission().then(function(permission){
if(Notification.permission!=='granted'){
alert("Please allow notification access!")
location.reload()
}
})
}
var timeoutIds= []
function scheduleReminder(){
var title=document.getElementById("title").value;
var description=document.getElementById('description').value;
var time=document.getElementById('time').value;
var date=document.getElementById('date').value;
var dateTimeString=date + " "+ time;
var scheduledTime=new Date(dateTimeString);
var currentTime=new Date();
var timeDifference=scheduledTime-currentTime;
if(timeDifference>0){
addReminder(title,description,dateTimeString);
var timeoutId=setTimeout(function(){
document.getElementById("notificationSound").play()
var notification=new Notification(title,{
body:description,
requireInteraction: true,
})
},timeDifference)
timeoutIds.push(timeoutId)
} else{
alert("The scheduled time is in the past!")
}
}
function addReminder(title,description,dateTimeString){
var tablebody=document.getElementById("reminderTableBody")
var row=tableBody.insertRow()
var titleCell= row.insertCell(0)
var descriptionCell= row.insertCell(1)
var dateTimeCell= row.insertCell(2)
var actionCell= row.insertCell(3)
titleCell.innerHTML=title
descriptionCell.innerHTML=description
dateTimeCell.innerHTML=dateTimeString
actionCell=`<button onclick= "deleteReminder(this);">Delete</button>`
}
</script> -->
</body>
</html>