-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
256 lines (239 loc) · 9.84 KB
/
index.html
File metadata and controls
256 lines (239 loc) · 9.84 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>LRU Cache Visualiser</title>
<link href="https://fonts.googleapis.com" rel="preconnect" />
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,[email protected],0..1&display=swap"
rel="stylesheet"
/>
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
<link rel="stylesheet" href="../shared.css" />
<link rel="stylesheet" href="style.css" />
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ["Inter", "sans-serif"],
},
colors: {
primary: "#3b82f6",
"primary-hover": "#2563eb",
secondary: "#8b5cf6",
hit: "#22c55e",
miss: "#ef4444",
evict: "#f59e0b",
surface: "#ffffff",
background: "#f8fafc",
},
},
},
};
</script>
</head>
<body
class="bg-background text-slate-800 font-sans min-h-screen flex flex-col"
>
<nav class="app-nav">
<div class="nav-inner">
<a class="brand" href="../index.html">DS Visualisers</a>
<div class="links">
<a class="link" href="../Hash Table Visualiser/index.html">Hash Table</a>
<a class="link" href="../Linked List Visualiser/index.html">Linked List</a>
<a class="link" href="../Queue Visualiser/index.html">Queue</a>
<a class="link" href="../Binary Search Visualiser/index.html">Binary Search</a>
<a class="link" href="../Convex Hull Visualiser/index.html">Convex Hull</a>
</div>
</div>
</nav>
<header
class="bg-surface/80 backdrop-blur-md border-b border-slate-200 sticky top-0 z-10"
>
<div
class="max-w-5xl mx-auto px-4 py-4 flex items-center justify-between"
>
<div class="flex items-center gap-3">
<div class="p-2 bg-primary/10 rounded-lg text-primary">
<span class="material-symbols-outlined">memory</span>
</div>
<h1 class="text-xl font-bold tracking-tight text-slate-900">
LRU Cache Visualiser
</h1>
</div>
<a
href="../index.html"
class="text-sm font-medium text-slate-500 hover:text-slate-800 transition-colors flex items-center gap-1"
>
<span class="material-symbols-outlined text-[18px]">arrow_back</span>
Back
</a>
</div>
</header>
<main
class="flex-1 max-w-5xl mx-auto w-full p-4 md:p-8 grid md:grid-cols-[300px_1fr] gap-8"
>
<!-- Controls -->
<div class="flex flex-col gap-6">
<div
class="bg-surface p-6 rounded-2xl shadow-card border border-slate-100"
>
<h2 class="text-lg font-semibold mb-4 flex items-center gap-2">
<span class="material-symbols-outlined text-slate-400">tune</span>
Operations
</h2>
<div class="flex flex-col gap-4">
<div class="space-y-2">
<label class="text-xs font-semibold text-slate-500 uppercase">Key</label>
<input
id="key-input"
type="text"
placeholder="Enter key (e.g., A, B, 1)"
class="w-full px-3 py-2 border border-slate-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
</div>
<div class="space-y-2">
<label class="text-xs font-semibold text-slate-500 uppercase">Value</label>
<input
id="value-input"
type="text"
placeholder="Enter value"
class="w-full px-3 py-2 border border-slate-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
</div>
<div class="grid grid-cols-2 gap-2">
<button
id="put-btn"
class="bg-primary hover:bg-primary-hover text-white px-4 py-2 rounded-lg font-medium transition-colors flex items-center justify-center gap-2"
>
<span class="material-symbols-outlined text-[18px]">add</span>
Put
</button>
<button
id="get-btn"
class="bg-slate-100 hover:bg-slate-200 text-slate-700 px-4 py-2 rounded-lg font-medium transition-colors flex items-center justify-center gap-2"
>
<span class="material-symbols-outlined text-[18px]">search</span>
Get
</button>
</div>
<button
id="clear-btn"
class="w-full bg-slate-100 hover:bg-slate-200 text-slate-700 px-4 py-2 rounded-lg font-medium transition-colors flex items-center justify-center gap-2"
>
<span class="material-symbols-outlined text-[18px]">delete</span>
Clear Cache
</button>
<div class="space-y-3 pt-3 border-t border-slate-100">
<div
class="flex items-center justify-between text-xs font-semibold text-slate-500 uppercase"
>
<span>Capacity</span>
<span id="capacity-value" class="text-slate-700 text-sm font-bold">4</span>
</div>
<input
id="capacity-input"
type="range"
min="2"
max="8"
step="1"
value="4"
class="w-full accent-blue-500"
/>
</div>
</div>
</div>
<!-- Stats -->
<div
class="bg-surface p-6 rounded-2xl shadow-card border border-slate-100 flex-1"
>
<h2 class="text-lg font-semibold mb-4 flex items-center gap-2">
<span class="material-symbols-outlined text-slate-400">analytics</span>
Stats
</h2>
<div class="space-y-4">
<div class="flex justify-between text-sm">
<span class="text-slate-500">Size / Capacity</span>
<span class="font-mono font-bold"><span id="size-display">0</span> / <span id="cap-display">4</span></span>
</div>
<div class="flex justify-between text-sm">
<span class="text-slate-500">Hits</span>
<span id="hits-display" class="font-mono font-bold text-green-600">0</span>
</div>
<div class="flex justify-between text-sm">
<span class="text-slate-500">Misses</span>
<span id="misses-display" class="font-mono font-bold text-red-600">0</span>
</div>
<div class="flex justify-between text-sm">
<span class="text-slate-500">Evictions</span>
<span id="evictions-display" class="font-mono font-bold text-amber-600">0</span>
</div>
<div class="p-3 bg-slate-50 rounded-lg min-h-[60px] mt-4">
<p id="message-box" class="text-sm text-slate-600 leading-snug">
Enter a key-value pair and click Put, or enter a key and click Get.
</p>
</div>
</div>
</div>
</div>
<!-- Visualization Area -->
<div
class="bg-surface rounded-2xl shadow-card border border-slate-100 p-6 flex flex-col relative overflow-hidden min-h-[500px]"
>
<div class="flex items-center justify-between mb-6">
<h3 class="font-semibold text-slate-700">Doubly Linked List (MRU → LRU)</h3>
<div class="flex gap-4 text-xs font-medium">
<div class="flex items-center gap-1">
<div class="w-3 h-3 bg-green-500 rounded"></div>
Hit
</div>
<div class="flex items-center gap-1">
<div class="w-3 h-3 bg-red-500 rounded"></div>
Miss
</div>
<div class="flex items-center gap-1">
<div class="w-3 h-3 bg-amber-500 rounded"></div>
Evicted
</div>
</div>
</div>
<!-- List View -->
<div class="flex-1 flex flex-col gap-6">
<div class="flex items-center gap-2 text-sm text-slate-500">
<span class="material-symbols-outlined text-[16px]">first_page</span>
<span>HEAD (Most Recent)</span>
</div>
<div id="list-container" class="flex flex-wrap items-center gap-4 min-h-[100px] p-4 bg-slate-50 rounded-xl">
<div class="text-slate-400 italic">Cache is empty</div>
</div>
<div class="flex items-center gap-2 text-sm text-slate-500">
<span class="material-symbols-outlined text-[16px]">last_page</span>
<span>TAIL (Least Recent)</span>
</div>
</div>
<!-- Hash Map View -->
<div class="mt-6 pt-6 border-t border-slate-200">
<h3 class="font-semibold text-slate-700 mb-4">Hash Map</h3>
<div id="map-container" class="grid grid-cols-4 gap-2">
<div class="text-slate-400 italic text-sm">No entries</div>
</div>
</div>
<!-- Operation Log -->
<div class="mt-6 pt-6 border-t border-slate-200">
<h3 class="font-semibold text-slate-700 mb-4">Operation Log</h3>
<div id="log-container" class="h-24 overflow-y-auto bg-slate-900 rounded-lg p-3 font-mono text-xs text-slate-300">
<div class="text-slate-500">// Operations will appear here...</div>
</div>
</div>
</div>
</main>
<script src="script.js"></script>
</body>
</html>