/* eslint-disable camelcase */ (() => { const containerEl = document.querySelector('[shopby-footer-container]'); const shortcut = { async initialize(commonData) { await this.replaceManifestWith(this.generateManifestUrl(commonData)); this.executeServiceWorker(); }, replaceManifestWith(manifestURL) { const manifestPlaceholderEl = document.querySelector('[shopby-manifest-placeholder]'); manifestPlaceholderEl?.setAttribute('href', manifestURL); }, generateManifestUrl(commonData) { const mallName = commonData.mallConfig.mall?.mallName; const manifest = { name: mallName, short_name: mallName, description: mallName, start_url: location.origin, display: 'standalone', orientation: 'portrait', incognito: 'split', icons: [ { src: `https:${commonData.bannerConfig?.appIcon}`, sizes: '144x144', type: 'image/png', purpose: 'any', }, ], }; const blob = new Blob([JSON.stringify(manifest)], { type: 'application/json' }); return URL.createObjectURL(blob); }, executeServiceWorker() { this.deferPromptEvent(); }, deferPromptEvent() { window.addEventListener('beforeinstallprompt', (event) => { event.preventDefault(); window.deferredPrompt = event; }); window.addEventListener('appinstalled', (event) => { event.preventDefault(); window.deferredPrompt = null; }); }, }; const CLICK_EVENT_HANDLER_MAP = { HANDLE_ADD_TO_HOME_BTN_CLICK: async () => { const promptEvent = window.deferredPrompt; if (!promptEvent) return; promptEvent.prompt(); const { outcome } = await promptEvent.userChoice; if (outcome === 'accepted') { // eslint-disable-next-line require-atomic-updates window.deferredPrompt = null; window.close(); } }, }; const clickEventListener = (e) => { const action = e.target.getAttribute('shopby-action'); CLICK_EVENT_HANDLER_MAP[action]?.(e); }; containerEl?.addEventListener('click', clickEventListener); /* 채널톡 */ (function(){var w=window;if(w.ChannelIO){return w.console.error("ChannelIO script included twice.");}var ch=function(){ch.c(arguments);};ch.q=[];ch.c=function(args){ch.q.push(args);};w.ChannelIO=ch;function l(){if(w.ChannelIOInitialized){return;}w.ChannelIOInitialized=true;var s=document.createElement("script");s.type="text/javascript";s.async=true;s.src="https://cdn.channel.io/plugin/ch-plugin-web.js";var x=document.getElementsByTagName("script")[0];if(x.parentNode){x.parentNode.insertBefore(s,x);}}if(document.readyState==="complete"){l();}else{w.addEventListener("DOMContentLoaded",l);w.addEventListener("load",l);}})(); ChannelIO('boot', { "pluginKey": "87efb631-afaf-43c4-b168-d899e79cab45", "customLauncherSelector": "#quick-menu-btn-ask", "hideChannelButtonOnBoot": true }); ChannelIO('onBadgeChanged', function onBadgeChanged(unread, alert) { // unread는 유저가 읽지 않은 모든 메시지 숫자입니다. // alert는 유저가 읽지 않은 주요 메시지 숫자입니다. // 채널 버튼에서 숫자로 알림이 표현됩니다. // console.log(`Unread is changed to ${unread}, alert is changed to ${alert}.`); const btnEl = document.getElementById('quick-menu-btn-ask-badge') const txtEl = document.getElementById('quick-menu-btn-ask-badge-txt') txtEl.innerText = alert if (alert > 0) { btnEl.classList.remove('custom__quick-menu__btn__icon__badge--hidden') } else { btnEl.classList.add('custom__quick-menu__btn__icon__badge--hidden') } }); })();