var __isInNativeAppShellContainer = false; var __isInNativeIosAppShellContainer = false; var requestAppShellVerifactionTimer; var checkContainerFooterLink = null; function checkContainerAction( senderId, noneAppShellContainerUrlCall, androidAppShellContainerUrlCall, iosAppShellContainerUrlCall ) { var context = window; if (typeof Android !== 'undefined' && Android !== null) { context = Android; } else if ( typeof webkit !== 'undefined' && webkit !== null && typeof webkit.messageHandlers !== 'undefined' && webkit.messageHandlers !== null ) { if ( typeof webkit.messageHandlers.appShellScriptMessageHandler !== 'undefined' && webkit.messageHandlers.appShellScriptMessageHandler !== null ) { // this is iOS App Shell Container __isInNativeIosAppShellContainer = true; var messgeToPost = { requestVerifyingWebContentConatiner: { 'name': iosAppShellContainerUrlCall, 'senderId': senderId } }; webkit.messageHandlers.appShellScriptMessageHandler.postMessage(messgeToPost); return; } } requestAppShellVerifactionTimer = setTimeout(noneAppShellContainerUrlCall(senderId), 100); try { // this is android App Shell Container context.requestVerifyingWebContentConatiner(androidAppShellContainerUrlCall, senderId); } catch (e) {} } function dummyCallBack(senderId) { __isInNativeAppShellContainer = false; } function updateIsContainerCallBack(senderId) { __isInNativeAppShellContainer = true; /* var heads = document.getElementsByTagName("header"); if (heads.length > 0 ) { heads[0].style.display = "none"; } var tails = document.getElementsByTagName("footer"); if (tails.length > 0 ) { tails[0].style.display = "none"; } */ } function isClientSiteForAppShell(url) { if(url == null || url === 'undefined') { return false; } return (url.indexOf("__appShellClientSite=true") > -1); } function openiFrameModal(url) { if (isClientSiteForAppShell(url)) { window.open(url); return; } var modalContainer = document.getElementById('iframeModalContainer'); if (typeof modalContainer === 'undefined' || modalContainer === null) { return; } var modalContent = document.getElementById('iframeModalContent'); if (typeof modalContent === 'undefined' || modalContent === null) { return; } var modalCloseButton = document.getElementById('iframeModalClose'); if (typeof modalCloseButton === 'undefined' || modalCloseButton === null) { return; } var modalInnerContainer = document.getElementById('iframeModalInnerContainer'); if (typeof modalInnerContainer === 'undefined' && modalInnerContainer === null) { return; } modalContainer.style.display = 'block'; modalContent.src = url; modalContent.style.display = 'block'; modalCloseButton.onclick = function() { modalContent.src = "data:text/html;charset=utf-8," + escape(""); modalContainer.style.display = "none"; iframeModalContent.style.display = "none"; } }; function appendUrlParam(url, paramWithValue) { if(url == null || url === "undefined" || paramWithValue == null || paramWithValue === "undefined") { return url; } if(url.indexOf("?") >= 0){ return url+'&'+paramWithValue; }else { return url+'?'+paramWithValue; } } function showPushNotificationMenuItem() { if ((supportAppShellPushNotificationMenu() && __isInNativeAppShellContainer)||(__isInNativeAppShellContainer && supportPussNotifications())) { var pushNotificationMenuItem = document.getElementById("pushNotificationsMenuItem"); if (typeof pushNotificationMenuItem !== 'undefined' && pushNotificationMenuItem != null) { pushNotificationMenuItem.setAttribute('class', 'over'); } } } function getIosPushNotificationAppShellValue(key, plId) { let support = false; try { const itemName = "__adesa.api.cache__/pageAttributes/" + plId; let pageAttributes = JSON.parse(localStorage.getItem(itemName)); if ( pageAttributes && pageAttributes.target) { let attrs = pageAttributes.target.attributes || []; for(let att of attrs || []) { if (att.type.id == '8') { const iosPushNotificationAppShell = att.type.iosPushNotificationAppShell || 'false'; if (iosPushNotificationAppShell == '0' || iosPushNotificationAppShell == 'true') { support = true; } break; } } } }catch(err) { console.log("Failed to read page attribute value iosPushNotificationAppShell"); return support; } return support; } function getAppShellPushNotificationValue(key, plId) { let support = false; try { const itemName = "__adesa.api.cache__/pageAttributes/" + plId; let pageAttributes = JSON.parse(localStorage.getItem(itemName)); if ( pageAttributes && pageAttributes.target) { let attrs = pageAttributes.target.attributes || []; for(let att of attrs || []) { if (att.type.id == '8') { const appShellPushNotificationValue = att.attributes.SHOW_APP_SHELL_PUSH_NOTIFICATION_MENU || 'false'; if (appShellPushNotificationValue == '1' || appShellPushNotificationValue == 'true') { support = true; } break; } } } }catch(err) { console.log("Failed to read page attribute value SHOW_APP_SHELL_PUSH_NOTIFICATION_MENU"); return support; } return support; } function supportPussNotifications() { const plId = getPrivateLabelId(); const support = getIosPushNotificationAppShellValue("iosPushNotificationAppShell",plId); return support; } function supportAppShellPushNotificationMenu() { const plId = getPrivateLabelId(); const support = getAppShellPushNotificationValue("SHOW_APP_SHELL_PUSH_NOTIFICATION_MENU",plId); return support; } function getPrivateLabelId() { var plId = 0; if (localStorage !== "undefined" && localStorage !== null && localStorage.getItem('siteInfo') !== "undefined" && localStorage.getItem('siteInfo') !== null) { plId = JSON.parse(localStorage.getItem('siteInfo')).privateLabelInfo.id; } return plId; } function restorePreservedUrl() { if (localStorage !== "undefined" && localStorage !== null) { let preservedUrl = localStorage.getItem('currentUrl'); if (preservedUrl !== null && preservedUrl !== "undefined") { window.location.href = preservedUrl; } } } function showPushNotificationSettingScreen() { if ((supportAppShellPushNotificationMenu() && __isInNativeAppShellContainer)||(__isInNativeAppShellContainer && supportPussNotifications())) { if (localStorage !== "undefined" && localStorage !== null) { localStorage.setItem('currentUrl', window.location.href); } var context = window; if (typeof Android !== "undefined" && Android !== null) { context = Android; } else if ( typeof webkit !== "undefined" && webkit !== null && typeof webkit.messageHandlers !== "undefined" && webkit.messageHandlers !== null ) { if (typeof webkit.messageHandlers.appShellScriptMessageHandler !== "undefined" && webkit.messageHandlers.appShellScriptMessageHandler !== null) { webkit.messageHandlers.appShellScriptMessageHandler.postMessage( {"showPushNotificationSetting": {"name": "pushNotificationSettingShowed"}} ); return; } } try { context.showPushNotificationSetting("pushNotificationSettingShowed"); } catch (e) {} } } function pushNotificationSettingShowed(refreshPage) { if (refreshPage) { window.location.reload(); } } setTimeout(checkContainerAction('checkContainerFooterLink', dummyCallBack, 'updateIsContainerCallBack', 'updateIsContainerCallBack'), 100); setTimeout(showPushNotificationMenuItem, 1000);