forked from Mirrors/keyoxide-web
Add QR code support
This commit is contained in:
parent
fcc1e8e57e
commit
8c5bf4b7e4
6 changed files with 53 additions and 1 deletions
1
assets/qrcode.min.js
vendored
Normal file
1
assets/qrcode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -621,7 +621,8 @@ let elFormVerify = document.body.querySelector("#form-verify"),
|
||||||
elProfileUid = document.body.querySelector("#profileUid"),
|
elProfileUid = document.body.querySelector("#profileUid"),
|
||||||
elProfileMode = document.body.querySelector("#profileMode"),
|
elProfileMode = document.body.querySelector("#profileMode"),
|
||||||
elModeSelect = document.body.querySelector("#modeSelect"),
|
elModeSelect = document.body.querySelector("#modeSelect"),
|
||||||
elUtilWKD = document.body.querySelector("#form-util-wkd");
|
elUtilWKD = document.body.querySelector("#form-util-wkd"),
|
||||||
|
elUtilQR = document.body.querySelector("#form-util-qr");
|
||||||
|
|
||||||
if (elModeSelect) {
|
if (elModeSelect) {
|
||||||
elModeSelect.onchange = function (evt) {
|
elModeSelect.onchange = function (evt) {
|
||||||
|
@ -798,3 +799,30 @@ if (elUtilWKD) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elUtilQR) {
|
||||||
|
elUtilQR.onsubmit = function (evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
const qrcode = new QRCode("qrcode", {
|
||||||
|
text: "",
|
||||||
|
width: 256,
|
||||||
|
height: 256,
|
||||||
|
colorDark : "#000000",
|
||||||
|
colorLight : "#ffffff",
|
||||||
|
correctLevel : QRCode.CorrectLevel.H
|
||||||
|
});
|
||||||
|
|
||||||
|
const elInput = document.body.querySelector("#input");
|
||||||
|
|
||||||
|
elInput.addEventListener("input", async function(evt) {
|
||||||
|
if (evt.target.value) {
|
||||||
|
qrcode.makeCode(evt.target.value);
|
||||||
|
} else {
|
||||||
|
qrcode.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
elInput.dispatchEvent(new Event("input"));
|
||||||
|
}
|
||||||
|
|
|
@ -202,6 +202,12 @@ a.proofUrl.proofUrl--verified {
|
||||||
a.proofUrl:hover {
|
a.proofUrl:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#qrcode img {
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 32px auto 16px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 680px) {
|
@media (max-width: 680px) {
|
||||||
#profileHeader {
|
#profileHeader {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
@ -14,6 +14,7 @@ $templates = new League\Plates\Engine('views');
|
||||||
$router->map('GET', '/', function() {}, 'index');
|
$router->map('GET', '/', function() {}, 'index');
|
||||||
$router->map('GET', '/guides', function() {}, 'guides');
|
$router->map('GET', '/guides', function() {}, 'guides');
|
||||||
$router->map('GET', '/guides/[:id]', function() {}, 'guideId');
|
$router->map('GET', '/guides/[:id]', function() {}, 'guideId');
|
||||||
|
$router->map('GET', '/util/qr/[:fp]', function() {}, 'util_qr');
|
||||||
$router->map('GET', '/util/[:id]', function() {}, 'util');
|
$router->map('GET', '/util/[:id]', function() {}, 'util');
|
||||||
$router->map('GET', '/faq', function() {}, 'faq');
|
$router->map('GET', '/faq', function() {}, 'faq');
|
||||||
$router->map('GET', '/verify', function() {}, 'verify');
|
$router->map('GET', '/verify', function() {}, 'verify');
|
||||||
|
@ -122,6 +123,11 @@ if(is_array($match) && is_callable($match['target'])) {
|
||||||
echo $templates->render("util/$id");
|
echo $templates->render("util/$id");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'util_qr':
|
||||||
|
$fp = htmlspecialchars($match['params']['fp']);
|
||||||
|
echo $templates->render("util/qr", ['input' => $fp]);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'faq':
|
case 'faq':
|
||||||
echo $templates->render("faq");
|
echo $templates->render("faq");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -39,5 +39,6 @@
|
||||||
</body>
|
</body>
|
||||||
<script src="/assets/openpgp.min.js"></script>
|
<script src="/assets/openpgp.min.js"></script>
|
||||||
<script src="/assets/spark-md5.min.js"></script>
|
<script src="/assets/spark-md5.min.js"></script>
|
||||||
|
<script src="/assets/qrcode.min.js"></script>
|
||||||
<script type="text/javascript" src="/assets/scripts.js" charset="utf-8"></script>
|
<script type="text/javascript" src="/assets/scripts.js" charset="utf-8"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
10
views/util/qr.php
Normal file
10
views/util/qr.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php $this->layout('template.base', ['title' => $title]) ?>
|
||||||
|
|
||||||
|
<h1>QR Code</h1>
|
||||||
|
<div class="content">
|
||||||
|
<form id="form-util-qr" method="post">
|
||||||
|
<h3>Fingeprint</h3>
|
||||||
|
<input type="text" name="input" id="input" placeholder="Fingerprint" value="<?=$this->escape($input)?>">
|
||||||
|
<div id="qrcode"></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
Loading…
Reference in a new issue