-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory.html
More file actions
311 lines (270 loc) · 10.7 KB
/
history.html
File metadata and controls
311 lines (270 loc) · 10.7 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
299
300
301
302
303
304
305
306
307
308
309
310
311
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vision History</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #0f0f10;
color: #ffffff;
margin: 0;
padding: 0;
height: 100vh;
display: flex;
flex-direction: column;
user-select: none;
}
.header {
background-color: #1c1c1e;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
padding: 1rem 2rem;
display: flex;
align-items: center;
gap: 2rem;
position: sticky;
top: 0;
z-index: 10;
}
.search-box {
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
display: flex;
align-items: center;
padding: 0 12px;
flex: 1;
max-width: 600px;
}
.search-box input {
background: transparent;
border: none;
outline: none;
color: white;
width: 100%;
height: 36px;
font-size: 14px;
padding: 0 8px;
}
.history-container {
flex: 1;
overflow-y: auto;
padding: 2rem;
max-width: 1000px;
margin: 0 auto;
width: 100%;
}
.history-day-group {
margin-bottom: 2rem;
}
.day-title {
font-size: 13px;
font-weight: 700;
color: #8b5cf6;
text-transform: uppercase;
letter-spacing: 0.1em;
margin-bottom: 1rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}
.history-item {
display: flex;
align-items: center;
padding: 10px 14px;
border-radius: 10px;
transition: all 0.2s ease;
cursor: pointer;
gap: 1rem;
margin-bottom: 2px;
}
.history-item:hover {
background: rgba(255, 255, 255, 0.03);
}
.item-time {
font-size: 12px;
color: rgba(255, 255, 255, 0.4);
min-width: 60px;
}
.favicon-container {
width: 18px;
height: 18px;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
}
.item-favicon {
width: 100%;
height: 100%;
border-radius: 3px;
object-fit: cover;
}
.favicon-fallback {
width: 100%;
height: 100%;
border-radius: 3px;
background: rgba(139, 92, 246, 0.1);
display: flex;
align-items: center;
justify-content: center;
font-size: 8px;
color: #8b5cf6;
font-weight: 900;
}
.item-title {
font-size: 14px;
font-weight: 500;
color: rgba(255, 255, 255, 0.9);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex: 1;
}
.item-url {
font-size: 12px;
color: rgba(255, 255, 255, 0.3);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 250px;
}
.item-actions {
opacity: 0;
transition: opacity 0.2s;
}
.history-item:hover .item-actions {
opacity: 1;
}
.btn-clear {
padding: 8px 16px;
background: #ef4444;
color: white;
border-radius: 6px;
font-size: 12px;
font-weight: 600;
transition: background 0.2s;
}
.btn-clear:hover {
background: #dc2626;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 50vh;
color: rgba(255, 255, 255, 0.2);
}
/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.1); }
</style>
</head>
<body>
<div class="header">
<div class="flex items-center gap-3">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#8b5cf6" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
<h1 class="font-bold text-lg">History</h1>
</div>
<div class="search-box">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.4)" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
<input type="text" id="search-input" placeholder="Search history">
</div>
<button id="clear-all" class="ml-auto btn-clear">Clear all</button>
</div>
<div id="history-container" class="history-container">
<!-- History items will be injected here -->
</div>
<script>
const container = document.getElementById('history-container');
const searchInput = document.getElementById('search-input');
const clearBtn = document.getElementById('clear-all');
function loadHistory() {
const history = JSON.parse(localStorage.getItem('vision_history') || '[]');
renderHistory(history);
}
function renderHistory(items) {
container.innerHTML = '';
const filter = searchInput.value.toLowerCase();
const filtered = items.filter(item =>
(item.title && item.title.toLowerCase().includes(filter)) ||
(item.url && item.url.toLowerCase().includes(filter))
);
if (filtered.length === 0) {
container.innerHTML = `
<div class="empty-state">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="mb-4"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
<p>${filter ? 'No entries match your search.' : 'Your browsing history is clean.'}</p>
</div>
`;
return;
}
// Group by date
const groups = {};
filtered.forEach(item => {
const date = new Date(item.time);
const dateStr = date.toLocaleDateString([], { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' });
if (!groups[dateStr]) groups[dateStr] = [];
groups[dateStr].push(item);
});
Object.entries(groups).forEach(([date, dayItems]) => {
const dayGroup = document.createElement('div');
dayGroup.className = 'history-day-group';
dayGroup.innerHTML = `<div class="day-title">${date}</div>`;
dayItems.forEach(item => {
const timeStr = new Date(item.time).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
const itemEl = document.createElement('div');
itemEl.className = 'history-item';
const faviconHtml = item.favicon
? `<img src="${item.favicon}" class="item-favicon" onerror="this.outerHTML='<div class=\\'favicon-fallback\\'>V</div>'">`
: `<div class="favicon-fallback">V</div>`;
itemEl.innerHTML = `
<div class="item-time">${timeStr}</div>
<div class="favicon-container">${faviconHtml}</div>
<div class="item-title" title="${item.title}">${item.title}</div>
<div class="item-url">${item.url}</div>
<div class="item-actions">
<button class="delete-item p-1 hover:bg-red-500/20 rounded transition-colors text-red-400" data-id="${item.id}">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
</div>
`;
itemEl.onclick = (e) => {
if (e.target.closest('.delete-item')) return;
window.parent.postMessage({ type: 'navigate', query: item.url }, '*');
};
itemEl.querySelector('.delete-item').onclick = (e) => {
e.stopPropagation();
deleteItem(item.id);
};
dayGroup.appendChild(itemEl);
});
container.appendChild(dayGroup);
});
}
function deleteItem(id) {
const history = JSON.parse(localStorage.getItem('vision_history') || '[]');
const updated = history.filter(item => item.id !== id);
localStorage.setItem('vision_history', JSON.stringify(updated));
renderHistory(updated);
}
clearBtn.onclick = () => {
if (confirm('Are you sure you want to clear your entire history?')) {
localStorage.setItem('vision_history', '[]');
renderHistory([]);
}
};
searchInput.oninput = () => {
const history = JSON.parse(localStorage.getItem('vision_history') || '[]');
renderHistory(history);
};
loadHistory();
window.addEventListener('focus', loadHistory);
</script>
</body>
</html>