;[...extend.entries()].forEach((param, i) => { params.append(param[0], param[1]); });
let iframe = document.createElement("iframe"); iframe.src = this.url; this.iframe = this.el.appendChild(iframe);
window.addEventListener('message', (e) => { this.messageListener(e); }); }
messageListener(event) { if (event.origin !== this.url.origin) return; if (event.source !== this.iframe.contentWindow) return; let data = JSON.parse(event.data);
switch (data.type) { case null: break;
case 'extendParams': let url = new URL(window.location); let params = new URLSearchParams(url.search); [...Object.entries(data.params)].forEach((param) => { if (params.has(param[0])) param[0] = param[0] + '2'; params.set(param[0], param[1]); }); url.search = params; window.history.replaceState('', '', url); break;
case 'anchorLink': if (document.getElementById(data.anchor) === null) break; const targetRect = document.getElementById(data.anchor).getBoundingClientRect(); let targetY = window.pageYOffset + targetRect.top; this.smoothScroll(targetY); break; } }
smoothScroll(position) { window.scrollTo({ top: position, behavior: 'smooth', }); } }
_.init = function () { var frame = new _.ExtendFrame(document.getElementById('exFrame')); }
})(sbFrameParent); document.addEventListener('DOMContentLoaded', sbFrameParent.init, false);