-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
147 lines (140 loc) · 4.71 KB
/
script.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
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
const notesData = [
{
id: 'notes-jT-jjsyz61J8XKiI',
title: 'Welcome to Notes, Dimas!',
body: 'Welcome to Notes! This is your first note. You can archive it, delete it, or create new ones.',
createdAt: '2022-07-28T10:03:12.594Z',
archived: false,
},
{
id: 'notes-aB-cdefg12345',
title: 'Meeting Agenda',
body: 'Discuss project updates and assign tasks for the upcoming week.',
createdAt: '2022-08-05T15:30:00.000Z',
archived: false,
},
{
id: 'notes-XyZ-789012345',
title: 'Shopping List',
body: 'Milk, eggs, bread, fruits, and vegetables.',
createdAt: '2022-08-10T08:45:23.120Z',
archived: false,
},
{
id: 'notes-1a-2b3c4d5e6f',
title: 'Personal Goals',
body: 'Read two books per month, exercise three times a week, learn a new language.',
createdAt: '2022-08-15T18:12:55.789Z',
archived: false,
},
{
id: 'notes-LMN-456789',
title: 'Recipe: Spaghetti Bolognese',
body: 'Ingredients: ground beef, tomatoes, onions, garlic, pasta. Steps:...',
createdAt: '2022-08-20T12:30:40.200Z',
archived: false,
},
{
id: 'notes-QwErTyUiOp',
title: 'Workout Routine',
body: 'Monday: Cardio, Tuesday: Upper body, Wednesday: Rest, Thursday: Lower body, Friday: Cardio.',
createdAt: '2022-08-25T09:15:17.890Z',
archived: false,
},
{
id: 'notes-abcdef-987654',
title: 'Book Recommendations',
body: "1. 'The Alchemist' by Paulo Coelho\n2. '1984' by George Orwell\n3. 'To Kill a Mockingbird' by Harper Lee",
createdAt: '2022-09-01T14:20:05.321Z',
archived: false,
},
{
id: 'notes-zyxwv-54321',
title: 'Daily Reflections',
body: 'Write down three positive things that happened today and one thing to improve tomorrow.',
createdAt: '2022-09-07T20:40:30.150Z',
archived: false,
},
{
id: 'notes-poiuyt-987654',
title: 'Travel Bucket List',
body: '1. Paris, France\n2. Kyoto, Japan\n3. Santorini, Greece\n4. New York City, USA',
createdAt: '2022-09-15T11:55:44.678Z',
archived: false,
},
{
id: 'notes-asdfgh-123456',
title: 'Coding Projects',
body: '1. Build a personal website\n2. Create a mobile app\n3. Contribute to an open-source project',
createdAt: '2022-09-20T17:10:12.987Z',
archived: false,
},
{
id: 'notes-5678-abcd-efgh',
title: 'Project Deadline',
body: 'Complete project tasks by the deadline on October 1st.',
createdAt: '2022-09-28T14:00:00.000Z',
archived: false,
},
{
id: 'notes-9876-wxyz-1234',
title: 'Health Checkup',
body: 'Schedule a routine health checkup with the doctor.',
createdAt: '2022-10-05T09:30:45.600Z',
archived: false,
},
{
id: 'notes-qwerty-8765-4321',
title: 'Financial Goals',
body: '1. Create a monthly budget\n2. Save 20% of income\n3. Invest in a retirement fund.',
createdAt: '2022-10-12T12:15:30.890Z',
archived: false,
},
{
id: 'notes-98765-54321-12345',
title: 'Holiday Plans',
body: 'Research and plan for the upcoming holiday destination.',
createdAt: '2022-10-20T16:45:00.000Z',
archived: false,
},
{
id: 'notes-1234-abcd-5678',
title: 'Language Learning',
body: 'Practice Spanish vocabulary for 30 minutes every day.',
createdAt: '2022-10-28T08:00:20.120Z',
archived: false,
},
];
document.addEventListener('DOMContentLoaded', () => {
const notesList = document.getElementById('notes-list');
if (!notesList) {
console.error('Elemen dengan ID "notes-list" tidak ditemukan');
return;
}
function renderNotes() {
notesList.innerHTML = '';
notesData.forEach(note => {
const noteItem = document.createElement('note-item');
noteItem.noteData = note;
notesList.appendChild(noteItem);
});
}
renderNotes();
const noteForm = document.querySelector('note-form');
// Cek apakah elemen dengan tag 'note-form' ada
if (!noteForm) {
console.error('Elemen dengan tag "note-form" tidak ditemukan');
return;
}
noteForm.addEventListener('add-note', (event) => {
const newNote = {
id: `notes-${Date.now()}`,
title: event.detail.title,
body: event.detail.body,
createdAt: new Date().toISOString(),
archived: false
};
notesData.push(newNote);
renderNotes();
});
});