window.addEventListener("load", function() { var pushSupported = false; if("safari" in window && "pushNotification" in window.safari){ pushSupported = true; } if (typeof(ServiceWorkerRegistration) != "undefined" && ("showNotification" in ServiceWorkerRegistration.prototype)) { pushSupported = true; } if(! pushSupported){ console.log("Browser not support push notification"); return false; } document.getElementsByTagName("HEAD")[0].insertAdjacentHTML('beforeend', ''); if("0" == "1"){ if(document.getElementById("smart_push_popup_fire")){ document.getElementById("smart_push_popup_fire").addEventListener("click", function(){ smart_push_build_quick_perm_popup(); }); if(smart_push_smio_getCookie("smart_push_device_token") != ""){ document.getElementById("smart_push_popup_fire").innerHTML = "Notification settings"; } else{ document.getElementById("smart_push_popup_fire").innerHTML = "Subscribe with us"; } } window.addEventListener("message", function (e) { if(e.data[0] == "action"){ return; } else if(e.data[0] == "" || e.data[1] == ""){ smart_push_smio_setCookie("smart_push_device_token", e.data[0], -1); smart_push_smio_setCookie("smart_push_device_type", e.data[1], -1); } else{ smart_push_smio_setCookie("smart_push_device_token", e.data[0], 365); smart_push_smio_setCookie("smart_push_device_type", e.data[1], 365); } }, false); window.addEventListener("message", function(event){ if(event.data[0] != "action" || smart_push_smio_getCookie("smart_push_smio_request") == "true"){ document.getElementById("smart_push_smio_overlay").style.display = "none"; return; } document.getElementById("smart_push_smio_overlay").style.opacity = "0.4"; document.getElementById("smart_push_smio_overlay").style.display = "block"; document.getElementById("smart_push_smio_window").style.position = "fixed"; document.getElementById("smart_push_smio_window").className += " smart_push_smio_responsive_window"; document.getElementById("smart_push_smio_window").style.left = "30%"; document.getElementById("smart_push_smio_window").style.top = "30%"; document.getElementById("smart_push_smio_window").style.width = "40%"; document.getElementById("smart_push_smio_window").style.display = "block"; document.getElementById("smart_push_smio_allow").addEventListener("click", function() { smart_push_build_quick_perm_popup(); }); return; }, false); document.getElementsByTagName("BODY")[0].insertAdjacentHTML('beforeend', '
Thanks for subscribing with us. Please click on finish as a final step to verify your subscription .
Powered by push.withct.co.za
'); document.getElementsByTagName("BODY")[0].insertAdjacentHTML('beforeend', ''); return; } else{ document.getElementsByTagName("BODY")[0].insertAdjacentHTML('beforeend', '
Welcome to our website. We would be delighted to send you notifications on new Product updates that could add value to your business.
You can turn off notifications in future if you do not wish to receive updates from us.
'); } if(document.getElementById("smart_push_popup_fire")){ document.getElementById("smart_push_popup_fire").addEventListener("click", function(){ if(smart_push_smio_getCookie("smart_push_device_token") != ""){ smart_push_open_subs_page(); } else{ smart_push_build_popup(); } }); if(smart_push_smio_getCookie("smart_push_device_token") != ""){ document.getElementById("smart_push_popup_fire").innerHTML = "Notification settings"; } else{ document.getElementById("smart_push_popup_fire").innerHTML = "Subscribe with us"; } } if("pageload" == "buttonclick"){ } else if("pageload" == "pagescroll" && smart_push_smio_getCookie("smart_push_smio_request") != "true"){ window.addEventListener("scroll", function(){ if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight/2) { smart_push_build_popup(); } }); } else if("pageload" == "pagetoend" && smart_push_smio_getCookie("smart_push_smio_request") != "true"){ window.addEventListener("scroll", function(){ if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { smart_push_build_popup(); } }); } else if(smart_push_smio_getCookie("smart_push_smio_request") != "true"){ setTimeout(function(){ smart_push_build_popup(); }, 1*1000); } document.getElementById("smart_push_smio_allow").addEventListener("click", function() { smart_push_open_subs_page(); }); if("0" != "1"){ document.getElementById("smart_push_smio_not_allow").addEventListener("click", function() { smart_push_smio_setCookie("smart_push_smio_request", "true", 7); document.getElementById("smart_push_smio_overlay").style.opacity = "0"; document.getElementById("smart_push_smio_overlay").style.display = "none"; if("modern" != "icon"){ document.getElementById("smart_push_smio_window").style.display = "none"; } }); document.getElementById("smart_push_smio_close").addEventListener("click", function() { smart_push_smio_setCookie("smart_push_smio_request", "true", 7); document.getElementById("smart_push_smio_overlay").style.opacity = "0"; document.getElementById("smart_push_smio_overlay").style.display = "none"; document.getElementById("smart_push_smio_window").style.display = "none"; }); } }); function smart_push_open_subs_page(){ if("modern" != "icon"){ smart_push_smio_setCookie("smart_push_smio_request", "true", 365); } if("floatwindow" == "newpage"){ var smpush_popwindow = window.open("https://push.withct.co.za/integration/permission/105982506/", "_blank"); } else{ var smpush_popwindow = window.open("https://push.withct.co.za/integration/permission/105982506/", "", "width=600,height=800"); } if("0" == "1"){ document.getElementById("smart_push_smio_note").innerHTML = "Please subscribe in our notification by clicking on allow button so you can continue browsing website."; } window.addEventListener("message", function (e) { if(e.data[0] == "" || e.data[1] == ""){ smart_push_smio_setCookie("smart_push_device_token", e.data[0], -1); smart_push_smio_setCookie("smart_push_device_type", e.data[1], -1); } else{ smart_push_smio_setCookie("smart_push_device_token", e.data[0], 365); smart_push_smio_setCookie("smart_push_device_type", e.data[1], 365); } }, false); var popupTick = setInterval(function() { if (smpush_popwindow.closed) { clearInterval(popupTick); if("0" == "1" && smart_push_smio_getCookie("smart_push_device_token") == ""){ return; } document.getElementById("smart_push_smio_overlay").style.opacity = "0"; document.getElementById("smart_push_smio_overlay").style.display = "none"; document.getElementById("smart_push_smio_window").style.display = "none"; } }, 1000); } function smart_push_build_quick_perm_popup(){ smart_push_smio_setCookie("smart_push_smio_request", "true", 365); if("floatwindow" == "newpage"){ window.open("https://push.withct.co.za/integration/permission/105982506/", "_blank"); } else{ window.open("https://push.withct.co.za/integration/permission/105982506/", "", "width=600,height=800"); } document.getElementById("smart_push_smio_overlay").style.opacity = "0"; document.getElementById("smart_push_smio_overlay").style.display = "none"; document.getElementById("smart_push_smio_window").style.display = "none"; } function smart_push_build_popup(){ document.getElementById("smart_push_smio_overlay").style.opacity = "0.4"; document.getElementById("smart_push_smio_window").style.position = "fixed"; if("modern" != "icon"){ document.getElementById("smart_push_smio_overlay").style.display = "block"; } document.getElementById("smart_push_smio_window").style.display = "block"; var position = "center"; if(position == "topright"){ document.getElementById("smart_push_smio_window").style.right = "10px"; document.getElementById("smart_push_smio_window").style.top = "10px"; } else if(position == "topleft"){ document.getElementById("smart_push_smio_window").style.left = "10px"; document.getElementById("smart_push_smio_window").style.top = "10px"; } else if(position == "botright"){ document.getElementById("smart_push_smio_window").style.bottom = "10px"; document.getElementById("smart_push_smio_window").style.right = "10px"; } else if(position == "botleft"){ document.getElementById("smart_push_smio_window").style.left = "10px"; document.getElementById("smart_push_smio_window").style.bottom = "10px"; } else if(position == "topcenter"){ document.getElementById("smart_push_smio_window").style.left = ((window.innerWidth/2) - (document.getElementById("smart_push_smio_window").offsetWidth/2)) + "px"; document.getElementById("smart_push_smio_window").style.top = "0"; } else{ document.getElementById("smart_push_smio_window").style.left = ((window.innerWidth/2) - (document.getElementById("smart_push_smio_window").offsetWidth/2)) + "px"; document.getElementById("smart_push_smio_window").style.top = ((window.innerHeight/2) - (document.getElementById("smart_push_smio_window").offsetHeight/2)) + "px"; } } function smpushSaveTag(tagname, value) { var subscriptionId = smpush_getCookie("smart_push_device_token"); var smpushDeviceType = smpush_getCookie("smart_push_device_type"); if(subscriptionId == ""){console.log("push service is not activated yet");return false;} if(smpushDeviceType == ""){console.log("push service is not activated yet");return false;} var params = "?device_token="+subscriptionId; params += "&device_type="+smpushDeviceType; params += "&active=1"; params += "&appid='.APPID.'"; params += "&"+tagname+"="+value; var url = "'.PUSH_API_URL.'/api/save_device/" + params; smpush_jsonp(url, function(data) { return true; }); } function smart_push_smio_setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + "; " + expires + ";path=/"; } function smart_push_smio_getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(";"); for(var i=0; i