mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-23 07:19:28 -07:00
Improve QR, add QR for fingerprint
This commit is contained in:
parent
08ca4d5d25
commit
484b2cb95e
3 changed files with 21 additions and 3 deletions
|
@ -146,7 +146,7 @@ class Claim extends HTMLElement {
|
||||||
|
|
||||||
const button_profileQR = subsection_qr_text.appendChild(document.createElement('button'));
|
const button_profileQR = subsection_qr_text.appendChild(document.createElement('button'));
|
||||||
button_profileQR.innerText = `Show profile QR`;
|
button_profileQR.innerText = `Show profile QR`;
|
||||||
button_profileQR.setAttribute('onClick', `showQR('${claim.matches[0].profile.qr}')`);
|
button_profileQR.setAttribute('onClick', `showQR('${claim.matches[0].profile.qr}', 'url')`);
|
||||||
}
|
}
|
||||||
|
|
||||||
elContent.appendChild(document.createElement('hr'));
|
elContent.appendChild(document.createElement('hr'));
|
||||||
|
|
|
@ -66,6 +66,19 @@ class Key extends HTMLElement {
|
||||||
|
|
||||||
const profile_link = subsection1_text.appendChild(document.createElement('p'));
|
const profile_link = subsection1_text.appendChild(document.createElement('p'));
|
||||||
profile_link.innerHTML = `Key link: <a href="${data.key.uri}">${data.key.uri}</a>`;
|
profile_link.innerHTML = `Key link: <a href="${data.key.uri}">${data.key.uri}</a>`;
|
||||||
|
|
||||||
|
elContent.appendChild(document.createElement('hr'));
|
||||||
|
|
||||||
|
// QR Code
|
||||||
|
const subsection_qr = elContent.appendChild(document.createElement('div'));
|
||||||
|
subsection_qr.setAttribute('class', 'subsection');
|
||||||
|
const subsection_qr_icon = subsection_qr.appendChild(document.createElement('img'));
|
||||||
|
subsection_qr_icon.setAttribute('src', '/static/img/qrcode.png');
|
||||||
|
const subsection_qr_text = subsection_qr.appendChild(document.createElement('div'));
|
||||||
|
|
||||||
|
const button_profileQR = subsection_qr_text.appendChild(document.createElement('button'));
|
||||||
|
button_profileQR.innerText = `Show OpenPGP fingerprint QR`;
|
||||||
|
button_profileQR.setAttribute('onClick', `showQR('${data.fingerprint}', 'fingerprint')`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ const fetchProfileKey = async function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable QR modal
|
// Enable QR modal
|
||||||
const showQR = function(input) {
|
const showQR = function(input, type) {
|
||||||
const qrTarget = document.getElementById('qr');
|
const qrTarget = document.getElementById('qr');
|
||||||
const qrContext = qrTarget.getContext('2d');
|
const qrContext = qrTarget.getContext('2d');
|
||||||
const qrOpts = {
|
const qrOpts = {
|
||||||
|
@ -143,7 +143,12 @@ const showQR = function(input) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (input) {
|
if (input) {
|
||||||
|
if (type === 'url') {
|
||||||
input = decodeURIComponent(input);
|
input = decodeURIComponent(input);
|
||||||
|
}
|
||||||
|
if (type === 'fingerprint') {
|
||||||
|
input = `OPENPGP4FPR:${input.toUpperCase()}`
|
||||||
|
}
|
||||||
|
|
||||||
QRCode.toCanvas(qrTarget, input, qrOpts, function(error) {
|
QRCode.toCanvas(qrTarget, input, qrOpts, function(error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
Loading…
Reference in a new issue