-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js.txt
More file actions
78 lines (70 loc) · 3.42 KB
/
script.js.txt
File metadata and controls
78 lines (70 loc) · 3.42 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
// script.js
document.addEventListener('DOMContentLoaded', () => {
const emojis = document.querySelectorAll('.emoji');
const notesBtn = document.getElementById('notes-btn');
const notesSection = document.getElementById('notes-section');
const saveNotesBtn = document.getElementById('save-notes-btn');
const moodNotesTextarea = document.getElementById('mood-notes');
const moodFeedbackDiv = document.getElementById('mood-feedback');
const selfCareBtn = document.getElementById('self-care-btn');
const selfCareModal = document.getElementById('self-care-modal');
const charityBtn = document.getElementById('charity-btn');
const charityListModal = document.getElementById('charity-list-modal');
const closeButtons = document.querySelectorAll('.close-button');
const moodAdvice = {
'happy': "That's wonderful! Keep spreading that positive energy. 😊",
'sad': "It's okay to feel sad. Remember to be kind to yourself. Maybe try a comforting activity? 🫂",
'angry': "Take a deep breath. It's important to process anger in a healthy way. Perhaps some calming music? 🧘♀️",
'stressed': "Remember to take breaks and prioritize self-care. You've got this! 💖",
'excited': "Fantastic! Enjoy that energy and enthusiasm! 🎉",
'calm': "Ah, a peaceful feeling. Savor this moment of tranquility. 🕊️",
'anxious': "It's alright to feel anxious. Try some grounding exercises. You are safe. 🌱",
'tired': "Listen to your body and get some rest. Recharging is important. 😴",
'loved': "That's a beautiful feeling. Cherish those connections. ❤️",
'surprised': "Well, that's interesting! How do you feel about this surprise? 🤔"
};
emojis.forEach(emoji => {
emoji.addEventListener('click', function() {
const mood = this.dataset.mood;
localStorage.setItem('currentMood', mood);
moodFeedbackDiv.textContent = moodAdvice[mood] || "";
moodFeedbackDiv.classList.remove('hidden');
// Hide feedback after a few seconds
setTimeout(() => {
moodFeedbackDiv.classList.add('hidden');
}, 5000);
});
});
notesBtn.addEventListener('click', () => {
notesSection.classList.remove('hidden');
});
saveNotesBtn.addEventListener('click', () => {
const notes = moodNotesTextarea.value;
localStorage.setItem('moodNotes', notes);
notesSection.classList.add('hidden');
alert('Notes saved locally!'); // Simple feedback for now
});
selfCareBtn.addEventListener('click', () => {
selfCareModal.classList.remove('hidden');
});
charityBtn.addEventListener('click', () => {
charityListModal.classList.remove('hidden');
});
closeButtons.forEach(button => {
button.addEventListener('click', function() {
const modal = this.closest('.modal');
if (modal) {
modal.classList.add('hidden');
}
});
});
// Close modal when clicking outside
window.addEventListener('click', (event) => {
if (event.target === selfCareModal) {
selfCareModal.classList.add('hidden');
}
if (event.target === charityListModal) {
charityListModal.classList.add('hidden');
}
});
});