Skip to content

Commit a896380

Browse files
committed
Add copy text to clipboard feature.
1 parent 0c7143b commit a896380

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

index.html

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf8"/>
5-
<title>Effindice Passphrase generator v0.4 = EFF Dice-Generated Passphrases for lazy people</title>
5+
<title>Effindice Passphrase generator v0.5 = EFF Dice-Generated Passphrases for lazy people</title>
66
<style>
77
*:not(p) {box-sizing: border-box; margin:0; font-family:system-ui, -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; text-align:center}
88
main {padding:20px}
@@ -32,13 +32,31 @@
3232
.result {min-height:200px; padding:40px 20px; background:#efefef; display:flex; align-items:center; justify-content: center; flex-direction:column; margin-bottom:10px; border-radius:10px;}
3333
.passphrase {padding: 0 0 15px 0; font-size:3em; cursor:text; line-height:1.1em;word-break: break-word}
3434
a {color: #000}
35+
#passphrase:hover,
36+
.item:hover {
37+
position:relative;
38+
cursor: pointer;
39+
}
40+
#passphrase:hover::after,
41+
.item:hover::after {
42+
content:'copy';
43+
display:block;
44+
position:absolute;
45+
color:rgba(0,0,0,.3);
46+
font-size:12px;
47+
line-height:1em;
48+
border-radius:.25em;
49+
right:10px;
50+
bottom:10px;
51+
}
52+
3553
</style>
3654
</head>
3755
<body onload="generatePassphrase()">
3856

3957
<main>
4058
<header>
41-
<h1>Effindice v0.4</h1>
59+
<h1>Effindice v0.5</h1>
4260
<h2>Dice-Generated Passphrases for lazy people </h2>
4361
<p>
4462
An experiment in digitizing the <a href="https://www.eff.org/dice">EFF Dice-Generated Passphrases</a> method using the <a href="https://en.wikipedia.org/wiki/Fortuna_(PRNG)">Fortuna pRNG</a>.<br/>
@@ -61,7 +79,7 @@ <h2>Dice-Generated Passphrases for lazy people </h2>
6179
</form>
6280
</div>
6381
<div class="result">
64-
<h3 id="passphrase" class="passphrase"></h3>
82+
<h3 id="passphrase" class="passphrase" onclick="copyTextToClipboard(this)"></h3>
6583
</div>
6684
<div id="numbersbox">
6785
<input id="numbers" type="text" readonly/>
@@ -87,6 +105,11 @@ <h3 id="passphrase" class="passphrase"></h3>
87105

88106
<script id="app">
89107

108+
function copyTextToClipboard(el){
109+
navigator.clipboard.writeText(el.innerText);
110+
console.debug(`copyTextToClipboard(): copied '${el.innerText}' to clipboard.`);
111+
}
112+
90113
fortuna.init();
91114

92115
const multiplepassphrases = document.getElementById('multiplepassphrases');
@@ -161,7 +184,7 @@ <h3 id="passphrase" class="passphrase"></h3>
161184
}
162185

163186
function displayPassphrase(multipleGenerator) {
164-
let loadingSuffix = '_';
187+
let loadingSuffix = '🎲';
165188
let diceRollGroups = numbers.value.trim().match(new RegExp('.{1,5}', 'g'));
166189
diceRollGroups = diceRollGroups.map(group => {
167190
if (group.length == 5) {
@@ -184,7 +207,7 @@ <h3 id="passphrase" class="passphrase"></h3>
184207
if (isCompletePassphrase && multipleGenerator) {
185208
const next = multipleGenerator.next();
186209

187-
multiplepassphrases.innerHTML = `<div class="item">${newPassphrase}</div>\n` + multiplepassphrases.innerHTML;
210+
multiplepassphrases.innerHTML = `<div class="item" onclick="copyTextToClipboard(this)">${newPassphrase}</div>\n` + multiplepassphrases.innerHTML;
188211
if (next.done) {
189212
generatemultiple.disabled = false;
190213
multiplecount.disabled = false;

0 commit comments

Comments
 (0)