-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvancedBookmarkManager.html
More file actions
298 lines (257 loc) · 9.79 KB
/
AdvancedBookmarkManager.html
File metadata and controls
298 lines (257 loc) · 9.79 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Bookmark Manager</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', sans-serif;
}
body {
min-height: 100vh;
background: linear-gradient(135deg, #2b2b2b, #4b4b4b);
padding: 2rem;
color: #fff;
}
.container {
max-width: 900px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.05);
border-radius: 15px;
padding: 2rem;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
}
h1 {
text-align: center;
margin-bottom: 2rem;
font-weight: 300;
color: #00ddeb;
text-shadow: 0 0 10px rgba(0, 221, 235, 0.3);
}
.input-section {
display: flex;
gap: 1rem;
margin-bottom: 2rem;
flex-wrap: wrap;
}
input, select {
padding: 0.8rem;
border: none;
border-radius: 8px;
background: rgba(255, 255, 255, 0.1);
color: #fff;
font-size: 1rem;
flex: 1;
}
input:focus, select:focus {
outline: none;
background: rgba(255, 255, 255, 0.2);
}
.add-btn {
background: #00ddeb;
color: #fff;
padding: 0.8rem 1.5rem;
border: none;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
}
.add-btn:hover {
background: #00b8c4;
transform: translateY(-2px);
}
.search-bar {
width: 100%;
max-width: 300px;
margin: 0 auto 2rem;
display: block;
}
.bookmarks {
display: flex;
flex-direction: column;
gap: 1rem;
}
.category {
background: rgba(255, 255, 255, 0.05);
border-radius: 10px;
padding: 1rem;
}
.category h2 {
color: #fff;
font-size: 1.2rem;
margin-bottom: 1rem;
font-weight: 400;
}
.bookmark-list {
list-style: none;
}
.bookmark-item {
background: rgba(255, 255, 255, 0.1);
padding: 1rem;
border-radius: 8px;
margin-bottom: 0.5rem;
display: flex;
align-items: center;
justify-content: space-between;
transition: all 0.3s ease;
cursor: move;
}
.bookmark-item:hover {
background: rgba(255, 255, 255, 0.15);
}
.bookmark-item.dragging {
opacity: 0.5;
}
.bookmark-link {
color: #00ddeb;
text-decoration: none;
flex: 1;
margin-right: 1rem;
}
.bookmark-link:hover {
text-decoration: underline;
}
.bookmark-actions button {
background: none;
border: none;
color: #fff;
cursor: pointer;
font-size: 1rem;
padding: 0.5rem;
transition: all 0.3s ease;
}
.edit-btn:hover { color: #ffeb3b; }
.delete-btn:hover { color: #ff4444; }
@media (max-width: 600px) {
.input-section { flex-direction: column; }
.container { padding: 1rem; }
.bookmark-item { flex-direction: column; align-items: flex-start; }
}
</style>
</head>
<body>
<div class="container">
<h1>Bookmark Manager</h1>
<div class="input-section">
<input type="text" id="bookmarkName" placeholder="Bookmark Name">
<input type="url" id="bookmarkUrl" placeholder="https://example.com">
<select id="bookmarkCategory">
<option value="General">General</option>
<option value="Work">Work</option>
<option value="Personal">Personal</option>
<option value="Entertainment">Entertainment</option>
</select>
<button class="add-btn" onclick="addBookmark()">Add</button>
</div>
<input type="text" class="search-bar" id="searchBar" placeholder="Search bookmarks..." onkeyup="searchBookmarks()">
<div class="bookmarks" id="bookmarks"></div>
</div>
<script>
let bookmarks = JSON.parse(localStorage.getItem('bookmarks')) || {
General: [], Work: [], Personal: [], Entertainment: []
};
function addBookmark() {
const name = document.getElementById('bookmarkName').value.trim();
const url = document.getElementById('bookmarkUrl').value.trim();
const category = document.getElementById('bookmarkCategory').value;
if (name && url) {
bookmarks[category].push({ name, url });
saveBookmarks();
renderBookmarks();
clearInputs();
}
}
function editBookmark(category, index) {
const newName = prompt('Edit bookmark name:', bookmarks[category][index].name);
const newUrl = prompt('Edit bookmark URL:', bookmarks[category][index].url);
if (newName && newUrl) {
bookmarks[category][index] = { name: newName, url: newUrl };
saveBookmarks();
renderBookmarks();
}
}
function deleteBookmark(category, index) {
if (confirm('Are you sure you want to delete this bookmark?')) {
bookmarks[category].splice(index, 1);
saveBookmarks();
renderBookmarks();
}
}
function saveBookmarks() {
localStorage.setItem('bookmarks', JSON.stringify(bookmarks));
}
function clearInputs() {
document.getElementById('bookmarkName').value = '';
document.getElementById('bookmarkUrl').value = '';
}
function renderBookmarks(filteredBookmarks = bookmarks) {
const bookmarksDiv = document.getElementById('bookmarks');
bookmarksDiv.innerHTML = '';
Object.keys(filteredBookmarks).forEach(category => {
if (filteredBookmarks[category].length > 0) {
const categoryDiv = document.createElement('div');
categoryDiv.className = 'category';
categoryDiv.innerHTML = `<h2>${category}</h2>`;
const ul = document.createElement('ul');
ul.className = 'bookmark-list';
ul.setAttribute('data-category', category);
filteredBookmarks[category].forEach((bookmark, index) => {
const li = document.createElement('li');
li.className = 'bookmark-item';
li.draggable = true;
li.innerHTML = `
<a href="${bookmark.url}" target="_blank" class="bookmark-link">${bookmark.name}</a>
<div class="bookmark-actions">
<button class="edit-btn" onclick="editBookmark('${category}', ${index})">✏️</button>
<button class="delete-btn" onclick="deleteBookmark('${category}', ${index})">🗑️</button>
</div>
`;
ul.appendChild(li);
});
categoryDiv.appendChild(ul);
bookmarksDiv.appendChild(categoryDiv);
// Drag and Drop
ul.addEventListener('dragstart', (e) => {
const item = e.target.closest('.bookmark-item');
if (item) item.classList.add('dragging');
});
ul.addEventListener('dragend', (e) => {
const item = e.target.closest('.bookmark-item');
if (item) item.classList.remove('dragging');
});
ul.addEventListener('dragover', (e) => e.preventDefault());
ul.addEventListener('drop', (e) => {
e.preventDefault();
const dragging = document.querySelector('.dragging');
const category = ul.getAttribute('data-category');
const draggedIndex = Array.from(ul.children).indexOf(dragging);
const dropTarget = e.target.closest('.bookmark-item');
const dropIndex = dropTarget ? Array.from(ul.children).indexOf(dropTarget) : ul.children.length;
const [movedItem] = bookmarks[category].splice(draggedIndex, 1);
bookmarks[category].splice(dropIndex, 0, movedItem);
saveBookmarks();
renderBookmarks();
});
}
});
}
function searchBookmarks() {
const query = document.getElementById('searchBar').value.toLowerCase();
const filteredBookmarks = {};
Object.keys(bookmarks).forEach(category => {
filteredBookmarks[category] = bookmarks[category].filter(bookmark =>
bookmark.name.toLowerCase().includes(query) || bookmark.url.toLowerCase().includes(query)
);
});
renderBookmarks(filteredBookmarks);
}
// Initial render
renderBookmarks();
</script>
</body>
</html>