-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.htm
328 lines (283 loc) · 10.5 KB
/
index.htm
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Secure Vault</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<style>
:root {
--primary-color: #6a11cb;
--secondary-color: #2575fc;
--background-color: #f4f4f9;
--card-color: #ffffff;
--text-color: #333;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
-webkit-tap-highlight-color: transparent;
}
body {
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
overflow-x: hidden;
}
.container {
background-color: var(--card-color);
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
width: 100%;
max-width: 400px;
padding: 30px;
position: relative;
overflow: hidden;
}
.app-title {
text-align: center;
color: var(--primary-color);
margin-bottom: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.app-title img {
width: 50px;
margin-right: 10px;
}
input {
width: 100%;
padding: 12px 15px;
margin: 10px 0;
border: 2px solid #e0e0e0;
border-radius: 10px;
transition: all 0.3s ease;
}
input:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 10px rgba(106, 17, 203, 0.2);
}
.password-strength {
width: 100%;
height: 5px;
background-color: #e0e0e0;
border-radius: 5px;
overflow: hidden;
margin-bottom: 10px;
}
.strength-bar {
width: 0%;
height: 100%;
background: linear-gradient(to right, red, yellow, green);
transition: width 0.5s;
}
.btn {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
color: white;
border: none;
border-radius: 10px;
cursor: pointer;
transition: transform 0.3s ease;
margin-top: 10px;
}
.btn:active {
transform: scale(0.95);
}
.notes-container {
margin-top: 20px;
}
.note {
background: linear-gradient(145deg, #f6d365, #fda085);
border-radius: 10px;
padding: 15px;
margin-bottom: 10px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.note:active {
transform: scale(0.98);
}
.note-actions {
display: flex;
align-items: center;
}
.note-actions button {
background: none;
border: none;
color: var(--primary-color);
margin-left: 10px;
cursor: pointer;
}
@media (max-width: 480px) {
body {
padding: 10px;
}
.container {
width: 100%;
max-width: 100%;
margin: 0;
height: 100vh;
border-radius: 0;
display: flex;
flex-direction: column;
}
}
/* PWA Specific Styles */
@media all and (display-mode: standalone) {
body {
background: var(--background-color);
}
}
</style>
</head>
<body>
<div class="container">
<div class="app-title">
<h1>🔐 Secure Vault</h1>
</div>
<!-- Master Password Setup -->
<div id="masterPasswordSetup">
<input
type="password"
id="masterPasswordInput"
placeholder="Create Master Password"
>
<div class="password-strength">
<div class="strength-bar" id="strengthBar"></div>
</div>
<button class="btn" id="saveMasterPassword">
Save Master Password
</button>
</div>
<!-- Note Creation -->
<div id="noteCreation" style="display:none;">
<input
type="text"
id="noteTitle"
placeholder="Note Title"
>
<input
type="text"
id="notePassword"
placeholder="Password to Save"
>
<button class="btn" id="addNote">
Add Secure Note
</button>
<!-- Saved Notes Container -->
<div id="savedNotes" class="notes-container"></div>
</div>
</div>
<script>
class PasswordVault {
constructor() {
this.masterPassword = null;
this.notes = [];
this.initializeEventListeners();
this.loadNotes();
}
initializeEventListeners() {
document.getElementById('masterPasswordInput').addEventListener('input', this.checkPasswordStrength.bind(this));
document.getElementById('saveMasterPassword').addEventListener('click', this.saveMasterPassword.bind(this));
document.getElementById('addNote').addEventListener('click', this.addNote.bind(this));
}
checkPasswordStrength() {
const password = document.getElementById('masterPasswordInput').value;
const strengthBar = document.getElementById('strengthBar');
let strength = 0;
if (password.length > 7) strength++;
if (password.match(/[a-z]/)) strength++;
if (password.match(/[A-Z]/)) strength++;
if (password.match(/[0-9]/)) strength++;
if (password.match(/[^a-zA-Z0-9]/)) strength++;
strengthBar.style.width = `${strength * 20}%`;
}
saveMasterPassword() {
const masterPassword = document.getElementById('masterPasswordInput').value;
if (masterPassword.length < 8) {
alert('Master password must be at least 8 characters long');
return;
}
this.masterPassword = masterPassword;
document.getElementById('masterPasswordSetup').style.display = 'none';
document.getElementById('noteCreation').style.display = 'block';
this.renderNotes();
}
addNote() {
const title = document.getElementById('noteTitle').value;
const password = document.getElementById('notePassword').value;
if (!title || !password) {
alert('Please fill in all fields');
return;
}
this.notes.push({ title, password });
this.saveNotes();
this.renderNotes();
document.getElementById('noteTitle').value = '';
document.getElementById('notePassword').value = '';
}
renderNotes() {
const savedNotesContainer = document.getElementById('savedNotes');
savedNotesContainer.innerHTML = '';
this.notes.forEach((note, index) => {
const noteElement = document.createElement('div');
noteElement.classList.add('note');
noteElement.textContent = note.title;
const noteActions = document.createElement('div');
noteActions.classList.add('note-actions');
const revealButton = document.createElement('button');
revealButton.textContent = 'Reveal';
revealButton.addEventListener('click', () => this.revealNote(index));
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', () => this.deleteNote(index));
noteActions.appendChild(revealButton);
noteActions.appendChild(deleteButton);
noteElement.appendChild(noteActions);
savedNotesContainer.appendChild(noteElement);
});
}
revealNote(index) {
const enteredPassword = prompt('Enter Master Password to view note:');
if (enteredPassword === this.masterPassword) {
alert(`Note Password: ${this.notes[index].password}`);
} else {
alert('Incorrect Master Password');
}
}
deleteNote(index) {
if (confirm('Are you sure you want to delete this note?')) {
this.notes.splice(index, 1);
this.saveNotes();
this.renderNotes();
}
}
saveNotes() {
localStorage.setItem('notes', JSON.stringify(this.notes));
}
loadNotes() {
const savedNotes = localStorage.getItem('notes');
if (savedNotes) {
this.notes = JSON.parse(savedNotes);
this.renderNotes();
}
}
}
document.addEventListener('DOMContentLoaded', () => {
new PasswordVault();
});
</script>
</body>
</html>