Add copy invite buttons

This commit is contained in:
Jacob Karlsson 2024-04-18 13:45:31 +02:00
parent e3fe7e88e4
commit 65211bd73a
5 changed files with 243 additions and 82 deletions

View File

@ -30,3 +30,23 @@ inviteLinkElem.onclick = function handleURI(ev) {
}, 5000)
window.location.replace(uri)
}
function copyText(text) {
const textArea = document.createElement("textarea")
textArea.value = text
textArea.style.position = "absolute"
textArea.style.left = "-999999px"
document.body.prepend(textArea)
textArea.select()
document.execCommand('copy')
textArea.remove()
}
const copyLinkElem = document.getElementById('copy')
copyLinkElem.onclick = function handleCopy(ev) {
copyText(uri);
copyLinkElem.innerHTML = copyLinkElem.innerHTML += '✓'
}

View File

@ -35,6 +35,27 @@ if (hash) {
// }, 5000);
// window.location.replace(uri);
// };
function copyText(text) {
const textArea = document.createElement("textarea")
textArea.value = text
textArea.style.position = "absolute"
textArea.style.left = "-999999px"
document.body.prepend(textArea)
textArea.select()
document.execCommand('copy')
textArea.remove()
}
const copyLinkElem = document.getElementById('copy')
copyLinkElem.onclick = function handleCopy(ev) {
copyText(uri);
copyLinkElem.innerHTML = copyLinkElem.innerHTML += '✓'
}
} else {
inviteLinkElem.classList.add('hidden')
failureElem.classList.remove('hidden')

View File

@ -1,25 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<article>
<h1>Bootstrap</h1>
<p>
Congratulations on successfully installing this Hub server!
Below is the bootstrap invite link, a one-time invite that will
set you up as the admin of this Hub.
</p>
<a id="invite" class="btn" href="#">Claim invite</a>
<p></p>
</article>
<script>
window.hubInvite = {
tcpPort: '<%= tcpPort %>',
shseCredentials: '<%= shseCredentials %>',
};
</script>
<script src="/bootstrap.js"></script>
</body>
</html>
<head>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<article>
<h1>Bootstrap</h1>
<p>
Congratulations on successfully installing this Hub server!
Below is the bootstrap invite link, a one-time invite that will
set you up as the admin of this Hub.
</p>
<a id="invite" class="btn" href="#">Claim invite</a>
or
<a id="copy" class="btn" href="#">Copy invite</a>
<p></p>
</article>
<script>
window.hubInvite = {
tcpPort: '<%= tcpPort %>',
shseCredentials: '<%= shseCredentials %>',
};
</script>
<script src="/bootstrap.js"></script>
</body>
</html>

View File

@ -1,17 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<article>
<h1>Join PPPPP</h1>
<a id="invite" class="btn" href="#">Claim invite</a>
<p id="failure" class="hidden">
Sorry, it seems like you have no actual invite code in the link you
opened.
</p>
</article>
<script src="/invite.js"></script>
</body>
</html>
<head>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<article>
<h1>Join PPPPP</h1>
<a id="invite" class="btn" href="#">Claim invite</a>
or
<a id="copy" class="btn" href="#">Copy invite</a>
<p id="failure" class="hidden">
Sorry, it seems like you have no actual invite code in the link you
opened.
</p>
</article>
<script src="/invite.js"></script>
</body>
</html>

198
package-lock.json generated
View File

@ -17,8 +17,9 @@
"ejs": "3.1.9",
"fastify": "4.25.2",
"pino": "8.17.2",
"ppppp-caps": "file:../caps",
"ppppp-keypair": "file:../keypair",
"ppppp-caps": "github:staltz/ppppp-caps",
"ppppp-keypair": "github:staltz/ppppp-keypair",
"ppppp-net": "github:staltz/ppppp-net",
"pull-cat": "1.1.11",
"pull-notify": "0.1.2",
"pull-stream": "3.7.0",
@ -39,34 +40,6 @@
"node": ">=16"
}
},
"../caps": {
"name": "ppppp-caps",
"version": "0.0.1",
"license": "CC0-1.0"
},
"../keypair": {
"name": "ppppp-keypair",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"b4a": "~1.6.4",
"bs58": "~5.0.0",
"mkdirp": "~3.0.1",
"sodium-universal": "~4.0.0"
},
"devDependencies": {
"@types/b4a": "^1.6.0",
"@types/node": "^20.2.5",
"c8": "^7.11.0",
"husky": "^4.3.0",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"typescript": "^5.0.2"
},
"engines": {
"node": ">=16"
}
},
"node_modules/@bcoe/v8-coverage": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
@ -231,6 +204,11 @@
"resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz",
"integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g=="
},
"node_modules/@types/pull-stream": {
"version": "3.6.7",
"resolved": "https://registry.npmjs.org/@types/pull-stream/-/pull-stream-3.6.7.tgz",
"integrity": "sha512-QO++onBb70RIPgGBUffbIVUsgLgjLPs893rRlAXJ8a80XGmV7lF5OvXDsfTP+kH/QlmaSTA38N57ZyrNTnD7KA=="
},
"node_modules/@types/unist": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
@ -2047,6 +2025,20 @@
"node": ">=10"
}
},
"node_modules/mkdirp": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
"integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
"bin": {
"mkdirp": "dist/cjs/src/bin.js"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/moo": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz",
@ -2223,6 +2215,11 @@
"node": ">=8"
}
},
"node_modules/obz": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/obz/-/obz-1.1.1.tgz",
"integrity": "sha512-eUiAX663dASOUIEWuRzUycf2ERZJFLbdjfzYRtju9z2eBfDPywcWjfyHV5JNbVoBjuHGVodyfeyy8Qu09+JCXw=="
},
"node_modules/on-change-network-strict": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/on-change-network-strict/-/on-change-network-strict-1.0.0.tgz",
@ -2390,12 +2387,50 @@
"integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA=="
},
"node_modules/ppppp-caps": {
"resolved": "../caps",
"link": true
"version": "0.0.1",
"resolved": "git+ssh://git@github.com/staltz/ppppp-caps.git#93fa810b9a40b78aef4872d4c2a8412cccb52929",
"license": "CC0-1.0"
},
"node_modules/ppppp-keypair": {
"resolved": "../keypair",
"link": true
"version": "0.0.1",
"resolved": "git+ssh://git@github.com/staltz/ppppp-keypair.git#c33980c580e33f9a35cb0c672b916ec9fe8b4c6d",
"license": "MIT",
"dependencies": {
"b4a": "~1.6.4",
"bs58": "~5.0.0",
"mkdirp": "~3.0.1",
"sodium-universal": "~4.0.0"
},
"engines": {
"node": ">=16"
}
},
"node_modules/ppppp-net": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/staltz/ppppp-net.git#5b79b9566bb425e27169f90544bc54b8b418b87c",
"license": "MIT",
"dependencies": {
"@types/pull-stream": "^3.6.7",
"atomic-file-rw": "^0.3.0",
"debug": "^4.3.2",
"has-network2": ">=0.0.3",
"ip": "^1.1.5",
"obz": "~1.1.0",
"on-change-network-strict": "1.0.0",
"on-wakeup": "^1.0.1",
"promisify-tuple": "^1.0.1",
"pull-awaitable": "1.0.0",
"pull-cat": "~1.1.11",
"pull-notify": "^0.1.2",
"pull-pause": "~0.0.2",
"pull-ping": "^2.0.3",
"pull-stream": "^3.6.14",
"statistics": "^3.3.0",
"ziii": "~1.0.2"
},
"engines": {
"node": ">=18"
}
},
"node_modules/prettier": {
"version": "2.8.8",
@ -2552,6 +2587,14 @@
"resolved": "https://registry.npmjs.org/pull-abortable/-/pull-abortable-4.1.1.tgz",
"integrity": "sha512-/zz8tW+T5tvtDc4NQVZTp3lJZoGEpUb2VDV3R5Q2/9lavNTwHK+hC5yF/3Q3LMmdn5AluFy23RFoqXIoySPl1w=="
},
"node_modules/pull-awaitable": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/pull-awaitable/-/pull-awaitable-1.0.0.tgz",
"integrity": "sha512-tfufzU9wMd1rM38tcgunaKMUNGXMj1Qms1ygEw+ZerkMmLAwilEtMsyzrDSLhNlnfhSzHXovOarieSNrTD1ovQ==",
"dependencies": {
"pull-thenable": "~1.0.0"
}
},
"node_modules/pull-box-stream": {
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/pull-box-stream/-/pull-box-stream-1.0.13.tgz",
@ -2676,6 +2719,14 @@
"resolved": "https://registry.npmjs.org/pull-stream/-/pull-stream-3.7.0.tgz",
"integrity": "sha512-Eco+/R004UaCK2qEDE8vGklcTG2OeZSVm1kTUQNrykEjDwcFXDZhygFDsW49DbXyJMEhHeRL3z5cRVqPAhXlIw=="
},
"node_modules/pull-thenable": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/pull-thenable/-/pull-thenable-1.0.0.tgz",
"integrity": "sha512-gio2Yanuj5lcN8X+VXtx6F2iWxnhxfaHSKaSJHUzJMNNboEz48/+udzZFDaya8kAwj3DbuFFt1pbb8m1tIS6PQ==",
"dependencies": {
"quicktask": "~1.0.0"
}
},
"node_modules/pull-through": {
"version": "1.0.18",
"resolved": "https://registry.npmjs.org/pull-through/-/pull-through-1.0.18.tgz",
@ -2719,6 +2770,11 @@
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
"integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg=="
},
"node_modules/quicktask": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/quicktask/-/quicktask-1.0.1.tgz",
"integrity": "sha512-+jhR01aSsi6Iw9wbYumKusRK72QK1ub2oE0kOnRyMkMdD/rXMMGW/TVl5edjcLjuuIKP1ezkr+xQzUMD5/4JHw=="
},
"node_modules/railroad-diagrams": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz",
@ -4088,6 +4144,11 @@
"resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz",
"integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g=="
},
"@types/pull-stream": {
"version": "3.6.7",
"resolved": "https://registry.npmjs.org/@types/pull-stream/-/pull-stream-3.6.7.tgz",
"integrity": "sha512-QO++onBb70RIPgGBUffbIVUsgLgjLPs893rRlAXJ8a80XGmV7lF5OvXDsfTP+kH/QlmaSTA38N57ZyrNTnD7KA=="
},
"@types/unist": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
@ -5351,6 +5412,11 @@
"brace-expansion": "^2.0.1"
}
},
"mkdirp": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
"integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg=="
},
"moo": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz",
@ -5496,6 +5562,11 @@
"path-key": "^3.0.0"
}
},
"obz": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/obz/-/obz-1.1.1.tgz",
"integrity": "sha512-eUiAX663dASOUIEWuRzUycf2ERZJFLbdjfzYRtju9z2eBfDPywcWjfyHV5JNbVoBjuHGVodyfeyy8Qu09+JCXw=="
},
"on-change-network-strict": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/on-change-network-strict/-/on-change-network-strict-1.0.0.tgz",
@ -5621,22 +5692,40 @@
"integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA=="
},
"ppppp-caps": {
"version": "file:../caps"
"version": "git+ssh://git@github.com/staltz/ppppp-caps.git#93fa810b9a40b78aef4872d4c2a8412cccb52929",
"from": "ppppp-caps@github:staltz/ppppp-caps"
},
"ppppp-keypair": {
"version": "file:../keypair",
"version": "git+ssh://git@github.com/staltz/ppppp-keypair.git#c33980c580e33f9a35cb0c672b916ec9fe8b4c6d",
"from": "ppppp-keypair@github:staltz/ppppp-keypair",
"requires": {
"@types/b4a": "^1.6.0",
"@types/node": "^20.2.5",
"b4a": "~1.6.4",
"bs58": "~5.0.0",
"c8": "^7.11.0",
"husky": "^4.3.0",
"mkdirp": "~3.0.1",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"sodium-universal": "~4.0.0",
"typescript": "^5.0.2"
"sodium-universal": "~4.0.0"
}
},
"ppppp-net": {
"version": "git+ssh://git@github.com/staltz/ppppp-net.git#5b79b9566bb425e27169f90544bc54b8b418b87c",
"from": "ppppp-net@github:staltz/ppppp-net",
"requires": {
"@types/pull-stream": "^3.6.7",
"atomic-file-rw": "^0.3.0",
"debug": "^4.3.2",
"has-network2": ">=0.0.3",
"ip": "^1.1.5",
"obz": "~1.1.0",
"on-change-network-strict": "1.0.0",
"on-wakeup": "^1.0.1",
"promisify-tuple": "^1.0.1",
"pull-awaitable": "1.0.0",
"pull-cat": "~1.1.11",
"pull-notify": "^0.1.2",
"pull-pause": "~0.0.2",
"pull-ping": "^2.0.3",
"pull-stream": "^3.6.14",
"statistics": "^3.3.0",
"ziii": "~1.0.2"
}
},
"prettier": {
@ -5747,6 +5836,14 @@
"resolved": "https://registry.npmjs.org/pull-abortable/-/pull-abortable-4.1.1.tgz",
"integrity": "sha512-/zz8tW+T5tvtDc4NQVZTp3lJZoGEpUb2VDV3R5Q2/9lavNTwHK+hC5yF/3Q3LMmdn5AluFy23RFoqXIoySPl1w=="
},
"pull-awaitable": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/pull-awaitable/-/pull-awaitable-1.0.0.tgz",
"integrity": "sha512-tfufzU9wMd1rM38tcgunaKMUNGXMj1Qms1ygEw+ZerkMmLAwilEtMsyzrDSLhNlnfhSzHXovOarieSNrTD1ovQ==",
"requires": {
"pull-thenable": "~1.0.0"
}
},
"pull-box-stream": {
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/pull-box-stream/-/pull-box-stream-1.0.13.tgz",
@ -5871,6 +5968,14 @@
"resolved": "https://registry.npmjs.org/pull-stream/-/pull-stream-3.7.0.tgz",
"integrity": "sha512-Eco+/R004UaCK2qEDE8vGklcTG2OeZSVm1kTUQNrykEjDwcFXDZhygFDsW49DbXyJMEhHeRL3z5cRVqPAhXlIw=="
},
"pull-thenable": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/pull-thenable/-/pull-thenable-1.0.0.tgz",
"integrity": "sha512-gio2Yanuj5lcN8X+VXtx6F2iWxnhxfaHSKaSJHUzJMNNboEz48/+udzZFDaya8kAwj3DbuFFt1pbb8m1tIS6PQ==",
"requires": {
"quicktask": "~1.0.0"
}
},
"pull-through": {
"version": "1.0.18",
"resolved": "https://registry.npmjs.org/pull-through/-/pull-through-1.0.18.tgz",
@ -5914,6 +6019,11 @@
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
"integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg=="
},
"quicktask": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/quicktask/-/quicktask-1.0.1.tgz",
"integrity": "sha512-+jhR01aSsi6Iw9wbYumKusRK72QK1ub2oE0kOnRyMkMdD/rXMMGW/TVl5edjcLjuuIKP1ezkr+xQzUMD5/4JHw=="
},
"railroad-diagrams": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz",