2021-05-02 04:49:52 -06:00
|
|
|
class Key extends HTMLElement {
|
|
|
|
// Specify the attributes to observe
|
|
|
|
static get observedAttributes() {
|
|
|
|
return ['data-keydata'];
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
// Call super
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
|
|
this.updateContent(newValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
updateContent(value) {
|
2021-05-04 05:57:33 -06:00
|
|
|
const root = this;
|
2021-05-02 04:49:52 -06:00
|
|
|
const data = JSON.parse(value);
|
|
|
|
|
2021-05-04 05:57:33 -06:00
|
|
|
root.querySelector('.info .subtitle').innerText = data.key.fetchMethod;
|
|
|
|
root.querySelector('.info .title').innerText = data.fingerprint;
|
2021-05-02 04:49:52 -06:00
|
|
|
|
2021-05-04 05:57:33 -06:00
|
|
|
const elContent = root.querySelector('.content');
|
2021-05-02 04:49:52 -06:00
|
|
|
elContent.innerHTML = ``;
|
|
|
|
|
|
|
|
// Link to key
|
2021-05-04 05:57:33 -06:00
|
|
|
const subsection_links = elContent.appendChild(document.createElement('div'));
|
|
|
|
subsection_links.setAttribute('class', 'subsection');
|
|
|
|
const subsection_links_icon = subsection_links.appendChild(document.createElement('img'));
|
|
|
|
subsection_links_icon.setAttribute('src', '/static/img/link.png');
|
2021-06-07 06:15:32 -06:00
|
|
|
subsection_links_icon.setAttribute('alt', '');
|
|
|
|
subsection_links_icon.setAttribute('aria-hidden', 'true');
|
2021-05-04 05:57:33 -06:00
|
|
|
const subsection_links_text = subsection_links.appendChild(document.createElement('div'));
|
2021-05-02 04:49:52 -06:00
|
|
|
|
2021-05-04 05:57:33 -06:00
|
|
|
const profile_link = subsection_links_text.appendChild(document.createElement('p'));
|
2021-05-02 04:49:52 -06:00
|
|
|
profile_link.innerHTML = `Key link: <a href="${data.key.uri}">${data.key.uri}</a>`;
|
2021-05-03 04:06:37 -06:00
|
|
|
|
|
|
|
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');
|
2021-06-07 06:15:32 -06:00
|
|
|
subsection_qr_icon.setAttribute('alt', '');
|
|
|
|
subsection_qr_icon.setAttribute('aria-hidden', 'true');
|
2021-05-03 04:06:37 -06:00
|
|
|
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')`);
|
2021-05-02 04:49:52 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define('kx-key', Key);
|