diff --git a/static/kx-claim.js b/static/kx-claim.js index 378242a..1919596 100644 --- a/static/kx-claim.js +++ b/static/kx-claim.js @@ -146,7 +146,7 @@ class Claim extends HTMLElement { const button_profileQR = subsection_qr_text.appendChild(document.createElement('button')); 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')); diff --git a/static/kx-key.js b/static/kx-key.js index f9e671b..78c821e 100644 --- a/static/kx-key.js +++ b/static/kx-key.js @@ -66,6 +66,19 @@ class Key extends HTMLElement { const profile_link = subsection1_text.appendChild(document.createElement('p')); profile_link.innerHTML = `Key link: ${data.key.uri}`; + + 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')`); } } diff --git a/static/scripts.js b/static/scripts.js index 14af431..e9fd9be 100644 --- a/static/scripts.js +++ b/static/scripts.js @@ -132,7 +132,7 @@ const fetchProfileKey = async function() { } // Enable QR modal -const showQR = function(input) { +const showQR = function(input, type) { const qrTarget = document.getElementById('qr'); const qrContext = qrTarget.getContext('2d'); const qrOpts = { @@ -143,7 +143,12 @@ const showQR = function(input) { }; if (input) { - input = decodeURIComponent(input); + if (type === 'url') { + input = decodeURIComponent(input); + } + if (type === 'fingerprint') { + input = `OPENPGP4FPR:${input.toUpperCase()}` + } QRCode.toCanvas(qrTarget, input, qrOpts, function(error) { if (error) {