-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
237 lines (201 loc) · 5.82 KB
/
index.html
File metadata and controls
237 lines (201 loc) · 5.82 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Password Generator</title>
<style>
body {
font-family: Arial, sans-serif;
background: #d7e7e8;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
background: white;
width: 420px;
padding: 25px;
border-radius: 15px;
box-shadow: 0 8px 20px rgba(0,0,0,0.2);
border-top: 6px solid #2f8f9d;
}
h2 {
text-align: center;
margin-top: 0;
font-size: 22px;
color: #2f8f9d;
}
.output-box {
display: flex;
justify-content: space-between;
align-items: center;
background: #f5f5f5;
padding: 10px 15px;
border-radius: 8px;
margin-bottom: 10px;
font-size: 18px;
box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}
.message {
font-size: 13px;
color: green;
margin-bottom: 10px;
}
button {
background: #2f8f9d;
color: white;
border: none;
padding: 10px 15px;
border-radius: 8px;
cursor: pointer;
margin-top: 12px;
width: 100%;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
transition: 0.2s;
}
button:hover {
background: #276d77;
}
.options {
margin-top: 15px;
}
.option-row {
display: flex;
justify-content: space-between;
margin: 8px 0;
}
input[type="checkbox"] {
width: 18px;
height: 18px;
cursor: pointer;
}
input[type="range"] {
width: 100%;
}
.length-box {
margin-top: 10px;
}
/* Popup for saved passwords */
.popup {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
padding: 20px;
border-radius: 15px;
width: 350px;
height: 300px;
box-shadow: 0 8px 20px rgba(0,0,0,0.3);
display: none;
flex-direction: column;
}
.popup textarea {
width: 100%;
height: 200px;
resize: none;
border-radius: 8px;
padding: 8px;
}
</style>
</head>
<body>
<div class="container">
<h2>Password Generator</h2>
<div class="output-box">
<span id="password">********</span>
<button style="width:auto;" onclick="copyPassword()">Copy</button>
</div>
<div id="message" class="message"></div>
<div class="length-box">
<label>Password Length: <span id="lenValue">12</span></label>
<input type="range" id="length" min="4" max="32" value="12" oninput="updateLength()">
</div>
<div class="options">
<div class="option-row">
<label>Uppercase</label>
<input type="checkbox" id="upper" checked>
</div>
<div class="option-row">
<label>Lowercase</label>
<input type="checkbox" id="lower" checked>
</div>
<div class="option-row">
<label>Numbers</label>
<input type="checkbox" id="numbers" checked>
</div>
<div class="option-row">
<label>Symbols</label>
<input type="checkbox" id="symbols" checked>
</div>
</div>
<button onclick="generatePassword()">Generate Password</button>
<button onclick="openPopup()">Show Saved Passwords</button>
</div>
<!-- Popup -->
<div class="popup" id="popup">
<textarea id="savedList"></textarea>
<button onclick="copyAll()">Copy All</button>
<button onclick="closePopup()">Close</button>
</div>
<script>
const password = document.getElementById("password");
const upperCheck = document.getElementById("upper");
const lowerCheck = document.getElementById("lower");
const numbersCheck = document.getElementById("numbers");
const symbolsCheck = document.getElementById("symbols");
const lenSlider = document.getElementById("length");
const lenValue = document.getElementById("lenValue");
const popup = document.getElementById("popup");
const savedList = document.getElementById("savedList");
function updateLength() {
lenValue.innerText = lenSlider.value;
}
function generatePassword() {
let length = parseInt(lenSlider.value);
let upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let lower = "abcdefghijklmnopqrstuvwxyz";
let numbers = "0123456789";
let symbols = "!@#$%^&*()_+";
let chars = "";
if(upperCheck.checked) chars += upper;
if(lowerCheck.checked) chars += lower;
if(numbersCheck.checked) chars += numbers;
if(symbolsCheck.checked) chars += symbols;
if(chars === "") {
alert("Select at least one option!");
return;
}
let pwd = "";
for(let i=0;i<length;i++) {
pwd += chars[Math.floor(Math.random() * chars.length)];
}
password.innerText = pwd;
// Save in LocalStorage
let saved = JSON.parse(localStorage.getItem("savedPwds")) || [];
saved.push(pwd);
localStorage.setItem("savedPwds", JSON.stringify(saved));
}
function copyPassword() {
navigator.clipboard.writeText(password.innerText);
alert("Password copied!");
}
function openPopup() {
let saved = JSON.parse(localStorage.getItem("savedPwds")) || [];
savedList.value = saved.join("\n");
popup.style.display = "flex";
}
function closePopup() {
popup.style.display = "none";
}
function copyAll() {
navigator.clipboard.writeText(savedList.value);
alert("All passwords copied!");
}
generatePassword();
</script>
</body>
</html>