const imgTemplate = document.createElement('template');
imgTemplate.innerHTML = `
<div class="wrapper">
<img id="noAttributeAndProperty" src="https://prowly-uploads.s3.eu-west-1.amazonaws.com/uploads/4843/assets/191020/large-09ba51481c9c5dd157eea3438af2bcbf.png" width="300" height="350"/>
<img id="falseAtribute" style="display: none" src="https://upload.wikimedia.org/wikipedia/en/1/14/WO%C5%9AP.svg" width="300" height="350"/>
<img id="trueAtribute" style="display: none" src="https://www.wroclaw.pl/go/download/img-32cf4a052df7bd08570783a8351863eb/wosp-26-jpg.jpg" width="300" height="350"/>
<img id="falseProperty" style="display: none" src="https://static.wosp.org.pl/trunk/uploaded/sended/files/programy/logo-rur-pl.png?1573732254027" width="300" height="350"/>
<img id="trueProperty" style="display: none" src="https://admonkey.pl/wp-content/uploads/2017/01/logo_wosp.jpg" width="300" height="350"/>
</div>`;
class ImgOnly extends HTMLElement {
constructor() {
super();
this.shadow = this.attachShadow({
mode: 'open'
});
}
getAtributesAndProperties() {
let atrGroup = null
let propsGroup = null
let element = document.getElementById('GesComplexComponent1_GesExternalWebComponent2-element')
if (!!element) {
atrGroup = element.getAttribute("atrgroup")
propsGroup = element['propsGroup']
}
if ((atrGroup == null || atrGroup == undefined) && (propsGroup == null || propsGroup == undefined)) {
this.shadow.getElementById("noAttributeAndProperty").style.display = "inline-block";
return;
} else {
element.shadowRoot.getElementById("noAttributeAndProperty").style.display = "none";
}
if (atrGroup === "true") {
element.shadowRoot.getElementById("trueAtribute").style.display = "inline-block";
element.shadowRoot.getElementById("falseAtribute").style.display = "none";
}
if (atrGroup === "false") {
element.shadowRoot.getElementById("falseAtribute").style.display = "inline-block";
element.shadowRoot.getElementById("trueAtribute").style.display = "none";
}
if (propsGroup === "true") {
element.shadowRoot.getElementById("trueProperty").style.display = "inline-block";
element.shadowRoot.getElementById("falseProperty").style.display = "none";
}
if (propsGroup === "false") {
element.shadowRoot.getElementById("falseProperty").style.display = "inline-block";
element.shadowRoot.getElementById("trueProperty").style.display = "none";
}
}
connectedCallback() {
this.shadow.appendChild(imgTemplate.content.cloneNode(true));
setInterval(this.getAtributesAndProperties, 500);
}
attributeChangedCallback(name, oldValue, newValue) {
switch (name) {
case 'atrgroup':
this.getAtributesAndProperties();
break;
}
}
static get observedAttributes() {
return ['atrgroup'];
}
}
window.customElements.define('img-only', ImgOnly);