-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared.js
More file actions
99 lines (91 loc) · 3.82 KB
/
Copy pathshared.js
File metadata and controls
99 lines (91 loc) · 3.82 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
// shared.js — Pure, environment-agnostic constants and utilities
// Used by both the Chrome extension (popup.js, newtab.js)
// and the GitHub Pages web app (docs/app.js).
// No chrome.* APIs, no fetch, no DOM — pure data & logic only.
const PHASE_LABELS = {
morning: '🌅 Morning Momentum',
focus: '🎯 Deep Focus',
wind_down: '🌙 Wind-Down',
night: '✨ Night Calm'
};
const PHASE_GREETINGS = {
morning: { sub: 'Good morning' },
focus: { sub: 'Stay focused' },
wind_down: { sub: 'Winding down' },
night: { sub: 'Good night' }
};
const RESET_EXERCISES = [
{
title: '🫧 Box Breathing (1 min)',
steps: [
'<strong>Breathe IN</strong> for 4 counts…',
'<strong>Hold</strong> for 4 counts…',
'<strong>Breathe OUT</strong> for 4 counts…',
'<strong>Hold</strong> for 4 counts…',
'Repeat 3–4 times. Feel the calm return. 🌿'
]
},
{
title: '🔍 5-4-3-2-1 Grounding',
steps: [
'Name <strong>5 things</strong> you can see right now.',
'Name <strong>4 things</strong> you can touch.',
'Name <strong>3 things</strong> you can hear.',
'Name <strong>2 things</strong> you can smell.',
'Name <strong>1 thing</strong> you can taste. You\'re here. 🌱'
]
},
{
title: '🧘 Quick Body Scan',
steps: [
'Close your eyes. Take one slow breath.',
'Notice your <strong>shoulders</strong>. Let them drop.',
'Notice your <strong>hands</strong>. Unclench them.',
'Notice your <strong>jaw</strong>. Soften it.',
'Feel your feet on the floor. You are grounded. ✨'
]
},
{
title: '🎯 One-Minute Reset',
steps: [
'Write down the <strong>one thing</strong> that matters most right now.',
'Everything else can wait.',
'Take 3 deep breaths.',
'Start with just <strong>one sentence</strong>.',
'Momentum will follow. 💪'
]
}
];
const FALLBACK_QUOTES = [
{ text: 'Take a breath. You\'re doing better than you think.', author: 'PulseCheck' },
{ text: 'Almost everything will work again if you unplug it for a few minutes — including you.', author: 'Anne Lamott' },
{ text: 'You don\'t have to be positive all the time. It\'s perfectly okay to feel sad, angry, annoyed, or anxious.', author: 'Lori Deschene' },
{ text: 'Breathe. Let go. And remind yourself that this very moment is the only one you know you have for sure.', author: 'Oprah Winfrey' },
{ text: 'In the middle of difficulty lies opportunity.', author: 'Albert Einstein' },
{ text: 'The present moment is the only moment available to us, and it is the door to all moments.', author: 'Thich Nhat Hanh' },
{ text: 'You are enough, just as you are.', author: 'Meghan Markle' },
{ text: 'Progress, not perfection.', author: 'PulseCheck' },
];
/** Returns the current phase name based on local time. */
function getCurrentPhase() {
const h = new Date().getHours();
if (h >= 6 && h < 10) return 'morning';
if (h >= 10 && h < 17) return 'focus';
if (h >= 17 && h < 22) return 'wind_down';
return 'night';
}
/** Formats a millisecond duration as MM:SS. */
function formatTime(ms) {
const totalSec = Math.max(0, Math.ceil(ms / 1000));
const m = Math.floor(totalSec / 60).toString().padStart(2, '0');
const s = (totalSec % 60).toString().padStart(2, '0');
return `${m}:${s}`;
}
/** Returns a random reset exercise. */
function getRandomExercise() {
return RESET_EXERCISES[Math.floor(Math.random() * RESET_EXERCISES.length)];
}
/** Returns a random fallback quote. */
function getRandomFallbackQuote() {
return FALLBACK_QUOTES[Math.floor(Math.random() * FALLBACK_QUOTES.length)];
}