-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmindful_background.js
35 lines (27 loc) · 999 Bytes
/
mindful_background.js
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
(function() {
var notification;
function myTimer() {
if (notification)
notification.cancel();
notification = webkitNotifications.createNotification(
"http://www.siyli.org/wp-content/themes/siy/images/search_yourself.jpg",
"Please Be Mindful",
"Take a few moments to close your eyes and do mindful focus on something such as your breathing, the feel of your keyboard, the sounds in the room, etc.");
notification.onclose = setMyTimer;
notification.show();
setMyCancelTimer();
}
function myCancelTimer() {
delete notification.onclose;
notification.cancel();
}
function setMyCancelTimer() {
setTimeout(myCancelTimer, Number(localStorage['cancelTime'] || 1000));
}
function setMyTimer() {
var baseTime = Number(localStorage['baseTime'] || 1000);
var randomTime = Number(localStorage['randomTime'] || 1000);
setTimeout(myTimer, baseTime + randomTime * Math.random());
}
setMyTimer();
})(this);