-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall-notes.html
More file actions
134 lines (128 loc) · 4.17 KB
/
all-notes.html
File metadata and controls
134 lines (128 loc) · 4.17 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>All Notes</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f0f0f0;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
}
h1 {
font-size: 24px;
text-align: center;
margin-bottom: 20px;
}
ul {
list-style-type: none;
padding: 0;
}
li {
background: #f9f9f9;
margin: 10px 0;
padding: 10px;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
}
.note-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.note-title {
font-weight: bold;
}
.note-date {
font-size: 12px;
color: #777;
}
.note-content {
margin-top: 10px;
}
.buttons {
display: flex;
gap: 10px;
margin-top: 10px;
}
.delete-button, .view-button {
background-color: #f9c0d2;
color: white;
border: none;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
}
.view-button {
background-color: #2196F3;
}
</style>
</head>
<body>
<div class="container">
<h1>All Notes</h1>
<ul id="note-list"></ul>
</div>
<script>
function loadAllNotes() {
const notes = JSON.parse(localStorage.getItem('notes')) || [];
const noteList = document.getElementById('note-list');
noteList.innerHTML = '';
notes.forEach((note, index) => {
const li = document.createElement('li');
const noteContent = note.note.length > 10 ? note.note.substring(0, 10) + '...' : note.note;
li.innerHTML = `
<div class="note-header">
<span class="note-title">${note.title}</span>
<span class="note-date">${note.date}</span>
</div>
<div class="note-content">${noteContent}</div>
<div class="buttons">
${note.note.length > 10 ? `<button class="view-button" onclick="viewNote(${index})">더보기</button>` : ''}
<button class="delete-button" onclick="deleteNote(${index})">Delete</button>
</div>
`;
noteList.appendChild(li);
});
}
function deleteNote(index) {
const notes = JSON.parse(localStorage.getItem('notes')) || [];
notes.splice(index, 1);
localStorage.setItem('notes', JSON.stringify(notes));
loadAllNotes();
loadCategories();
}
function viewNote(index) {
window.location.href = `view-note.html?index=${index}`;
}
function loadCategories() {
const notes = JSON.parse(localStorage.getItem('notes')) || [];
const categories = new Set();
notes.forEach(note => note.tags.forEach(tag => categories.add(tag)));
const categoryList = document.getElementById('category-list');
categoryList.innerHTML = '<li><a href="#" onclick="filterNotes(\'all\')">All</a></li>';
categories.forEach(category => {
const li = document.createElement('li');
li.innerHTML = `<a href="#" onclick="filterNotes('${category}')">${category}</a>`;
categoryList.appendChild(li);
});
}
window.onload = () => {
loadAllNotes();
loadCategories();
};
</script>
</body>
</html>