class UrlGenerator extends HTMLElement {
constructor() {
// Always call super first in constructor
super();
this.innerHTML =
`
URL
`;
}
/**
* Runs each time the element is appended to or moved in the DOM
*/
connectedCallback() {
}
/**
* Runs when the element is removed from the DOM
*/
disconnectedCallback() {
}
}
function generateURLQR() {
document.getElementById('generate-qr-button').disabled = true;
fetch(GENERATE_URL, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({ url: document.getElementById('url').value.trim(), type: 'URL' })
}).then(
function (response) {
return response.json();
}
)
.then(res => {
const url = res.rows[0].url;
generateQRCodeWithMessage(url);
document.getElementById('generate-qr-button').disabled = false;
});
}
function initURL() {
document.getElementById('qr-topic').innerHTML = `
`;
}
if ('customElements' in window) {
customElements.define('url-generator', UrlGenerator);
}