customElements.define('oswilno-price', class extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); } connectedCallback() { let shadow = this.shadowRoot; let price = parseInt(this.getAttribute('price')); if (isNaN(price)) price = 0; const multiplier = parseInt(this.getAttribute('multiplier')); let major = price; let minor = 0; if (!isNaN(multiplier)) { major = Math.floor(price / multiplier); minor = price % multiplier; } const currency = this.getAttribute('currency') || 'PLN'; shadow.innerHTML = `
${major}.${minor >= 10 ? minor : minor + '0'} ${ currency }
`; } });