-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
159 lines (140 loc) · 3.84 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<link data-trunk rel="scss" href="index.scss" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>KEYGEN</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color: #121212;
--accent-color: #ff7597;
--text-color: #e0e0e0;
--button-bg-color: #292929;
--button-hover-color: #ff7597;
}
body {
margin: 0;
padding: 0;
background-color: var(--bg-color);
color: var(--text-color);
font-family: 'Orbitron', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
}
h1 {
color: var(--accent-color);
text-transform: uppercase;
}
#generator {
display: flex;
flex-direction: column;
justify-content: space-between;
gap: 10px;
align-items: center;
}
#generator label,
#generator input {
flex: 1;
}
input[type="number"],
button {
padding: 10px 20px;
border: none;
background-color: var(--button-bg-color);
color: var(--text-color);
border-radius: 5px;
transition: background-color 0.3s;
width: 190px;
font-size: 15pt;
}
input[type="number"] {
width: 150px;
}
button:hover {
background-color: var(--button-hover-color);
cursor: pointer;
}
#passwordOutput {
margin-top: 20px;
padding: 15px;
background-color: var(--button-bg-color);
border-radius: 5px;
width: 80%;
text-align: center;
word-wrap: break-word;
}
@media (max-width: 768px) {
#passwordOutput {
width: 90%;
}
}
.highlight {
color: limegreen;
}
#passwordOutput {
cursor: pointer;
letter-spacing: 0.5em;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
background-color: var(--bg-color);
text-align: center;
padding: 10px 0;
}
footer a {
color: var(--text-color);
font-size: 24px;
text-decoration: none;
}
footer a:hover {
color: var(--accent-color);
}
</style>
</head>
<body>
<h1>KEYGEN.FI</h1>
<div id="generator">
<label for="length">NUMBER OF WORDS:</label>
<input type="number" id="length" name="length" min="1" max="10" value="3">
<button onclick="generatePassword()">Generate</button>
</div>
<div id="passwordOutput" onclick="copyToClipboard()">^ CLICK GENERATE ^</div>
<script>
function generatePassword() {
let password = "";
let length = document.getElementById('length').value;
password = wasmBindings.random_words(length);
let passwordOutput = document.getElementById('passwordOutput');
passwordOutput.innerText = password;
}
function copyToClipboard() {
let passwordOutput = document.getElementById('passwordOutput');
let passwordText = passwordOutput.textContent.replace(/\n/g, ''); // Remove newline characters
navigator.clipboard.writeText(passwordText).then(function () {
passwordOutput.innerText = 'Copied!';
passwordOutput.classList.add('highlight');
setTimeout(function () {
passwordOutput.innerText = passwordText;
passwordOutput.classList.remove('highlight');
}, 1000); // Change back after 2 seconds
}, function (err) {
console.error('Could not copy text: ', err);
});
}
</script>
<footer>
<a href="https://github.com/AlpakkaFarmi/keygen" target="_blank">
<i class="fab fa-github"></i>
</a>
</footer>
</body>
</html>