Updates to qr and qrfp

This commit is contained in:
Yarmo Mackenbach 2020-07-22 14:58:11 +02:00
parent c25e7e6ef1
commit 6f6ecf012e
3 changed files with 33 additions and 7 deletions

View file

@ -807,6 +807,7 @@ let elFormVerify = document.body.querySelector("#form-verify"),
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"),
elUtilQRFP = document.body.querySelector("#form-util-qrfp"),
elUtilQR = document.body.querySelector("#form-util-qr"), elUtilQR = document.body.querySelector("#form-util-qr"),
elUtilProfileURL = document.body.querySelector("#form-util-profile-url"); elUtilProfileURL = document.body.querySelector("#form-util-profile-url");
@ -1005,6 +1006,33 @@ if (elUtilWKD) {
}); });
} }
if (elUtilQRFP) {
elUtilQRFP.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(`OPENPGP4FPR:${evt.target.value.toUpperCase()}`);
} else {
qrcode.clear();
}
});
elInput.dispatchEvent(new Event("input"));
}
if (elUtilQR) { if (elUtilQR) {
elUtilQR.onsubmit = function (evt) { elUtilQR.onsubmit = function (evt) {
evt.preventDefault(); evt.preventDefault();
@ -1023,7 +1051,7 @@ if (elUtilQR) {
elInput.addEventListener("input", async function(evt) { elInput.addEventListener("input", async function(evt) {
if (evt.target.value) { if (evt.target.value) {
qrcode.makeCode(`OPENPGP4FPR:${evt.target.value.toUpperCase()}`); qrcode.makeCode(`${evt.target.value.toUpperCase()}`);
} else { } else {
qrcode.clear(); qrcode.clear();
} }

View file

@ -3,9 +3,7 @@
<div class="content"> <div class="content">
<h1>QR Code</h1> <h1>QR Code</h1>
<form id="form-util-qr" method="post"> <form id="form-util-qr" method="post">
<p>This tool generates a QR code containing the fingerprint of your public key (<a href="https://github.com/open-keychain/open-keychain/wiki/QR-Codes">format</a>). This QR code can be scanned by apps like <a href="https://www.openkeychain.org/">OpenKeyChain</a>.</p> <input type="hidden" name="input" id="input" placeholder="Fingerprint" value="<?=$this->escape($input)?>">
<h3>Fingerprint</h3>
<input type="text" name="input" id="input" placeholder="Fingerprint" value="<?=$this->escape($input)?>">
<div id="qrcode"></div>
</form> </form>
<div id="qrcode"></div>
</div> </div>

View file

@ -2,10 +2,10 @@
<div class="content"> <div class="content">
<h1>QR Code</h1> <h1>QR Code</h1>
<form id="form-util-qr" method="post"> <form id="form-util-qrfp" method="post">
<p>This tool generates a QR code containing the fingerprint of your public key (<a href="https://github.com/open-keychain/open-keychain/wiki/QR-Codes">format</a>). This QR code can be scanned by apps like <a href="https://www.openkeychain.org/">OpenKeyChain</a>.</p> <p>This tool generates a QR code containing the fingerprint of your public key (<a href="https://github.com/open-keychain/open-keychain/wiki/QR-Codes">format</a>). This QR code can be scanned by apps like <a href="https://www.openkeychain.org/">OpenKeyChain</a>.</p>
<h3>Fingerprint</h3> <h3>Fingerprint</h3>
<input type="text" name="input" id="input" placeholder="Fingerprint" value="<?=$this->escape($input)?>"> <input type="text" name="input" id="input" placeholder="Fingerprint" value="<?=$this->escape($input)?>">
<div id="qrcode"></div>
</form> </form>
<div id="qrcode"></div>
</div> </div>