"use strict"; var smpush_isPushEnabled=false; let firebaseInitialized=false; var devicetype=smpush_browser(); var settings=JSON.parse('{"chrome":0,"firefox":0,"opera":0,"edge":0,"samsung":0,"safari":0}'); smpush_debug(devicetype); function smpush_debug(error, object){ if(1==1){ if(typeof object!=="undefined"){ console.log(error, object); }else{ console.log(error); }} } function smpush_endpoint_subscribe(subscriptionId, oldToken){ if(subscriptionId==""){ return false; } smpush_setCookie("smpush_desktop_request", "true", 365); smpush_setCookie("smpush_device_token", subscriptionId, 60); var data={}; data["device_token"]=subscriptionId; data["device_type"]=devicetype; data["firebase"]=1; data["active"]=1; data["latitude"]=(smpush_getCookie("smart_push_smio_coords_latitude")!="")? smpush_getCookie("smart_push_smio_coords_latitude"):""; data["longitude"]=(smpush_getCookie("smart_push_smio_coords_longitude")!="")? smpush_getCookie("smart_push_smio_coords_longitude"):""; var subsChannels=[]; jQuery("input.smpush_desktop_channels_subs:checked").each(function(index){ subsChannels.push(jQuery(this).val()); });subsChannels=subsChannels.join(","); if(jQuery(".smpush-push-subscriptions-button").length > 0&&jQuery("#smpush_subscription_form").length==0){ var apiService="channels_subscribe"; data["channels_id"]=subsChannels; }else if(oldToken&&oldToken!=""){ var apiService="refresh_token"; data["device_old_token"]=oldToken; }else{ var apiService="savetoken"; } smpushDestroyReqWindow(false); jQuery.ajax({ method: "POST", url: "https://feedarco.com/?smpushcontrol="+apiService, data: data }) .done(function(msg){ smpushWelcomeMSG(); jQuery(".smpush-push-subscriptions-button").attr("disabled","disabled"); jQuery(".smpush-push-subscriptions-button").html("ذخیر شد"); smpush_debug("Data Sent"); if(1==1){ smpushUpdateGPS(); } smpush_link_user_cookies(); });} function smpush_endpoint_unsubscribe(subscriptionId){ jQuery("#smpushIconRequest").smiotooltipster("content","برای دریافت ااطلاعات محصولات و نوشته های سایت اعلان سایت را می پذیرم"); if(subscriptionId==""){ return false; } jQuery.ajax({ method: "POST", url: "https://feedarco.com/?smpushcontrol=deletetoken", data: { device_token: subscriptionId, device_type: devicetype, firebase: 1}}) .done(function(msg){ smpush_debug("Data Sent"); smpush_setCookie("smpush_linked_user", "false", -1); smpush_setCookie("smpush_safari_device_token", "false", -1); smpush_setCookie("smpush_device_token", "false", -1); smpush_setCookie("smpush_desktop_request", "false", -1); smpush_setCookie("smpush_desktop_welcmsg_seen", "false", -1); smpush_setCookie("smpush_desktop_blocked", "true", 365); location.reload(); });} function smpush_test_browser(){ if("safari" in window&&"pushNotification" in window.safari){ return true; } if(typeof(ServiceWorkerRegistration)!="undefined"&&("showNotification" in ServiceWorkerRegistration.prototype)){ return true; } if(Notification.permission==="denied"){ return false; } return false; } function smpush_browser(){ if("safari" in window){ return "safari"; } if(navigator.userAgent.indexOf(" OPR/") >=0){ return "opera"; } if(navigator.userAgent.indexOf("Edge") >=0){ return "edge"; } if(navigator.userAgent.match(/chrome/i)){ return "chrome"; } if(navigator.userAgent.match(/SamsungBrowser/i)){ return "samsung"; } if(navigator.userAgent.match(/firefox/i)){ return "firefox"; }} function smpush_bootstrap_init(){ jQuery(".smpush-push-resubscribe-button").on("click", function(){ smpush_debug("resubscribe clicked."); if(smpush_getCookie("smpush_desktop_blocked")=="true"&&"native"=="subs_page"){ smpush_setCookie("smpush_desktop_blocked", "false", -1); window.location.reload(false); }});if(settings[devicetype]==0){ smpush_debug("Browser support is closed by admin settings"); return; } var pushSupported=smpush_test_browser(); if(! pushSupported){ smpushDrawUnSupportedPopup(); smpush_debug("Browser not support push notification"); return; } if(smpush_getCookie("smpush_desktop_request")!="true"&&smpush_getCookie("smpush_desktop_blocked")!="true"){ jQuery("body").append("<style></style>"); setTimeout(function(){ smpushDrawReqWindow() }, 1000); }else{ smpush_link_user_cookies(); if(1==1){ smpushUpdateGPS(); }} setTimeout(function(){ smpushDrawReqIcon(); if("safari" in window){ smpushSafari(); }else{ smpushGeko(); }}, 1000); } function smpushUpdateGPS(){ if(smpush_getCookie("smpush_device_token")!=""&&smpush_getCookie("smart_push_smio_coords_latitude")==""){ if(! navigator.geolocation){ smpush_debug("Geolocation is not supported for this Browser/OS."); return; } var geoSuccess=function(startPos){ smpush_debug(startPos.coords.latitude); smpush_debug(startPos.coords.longitude); smpush_setCookie("smart_push_smio_coords_latitude", startPos.coords.latitude, (1/24)); smpush_setCookie("smart_push_smio_coords_longitude", startPos.coords.longitude, (1/24)); smpush_endpoint_subscribe(smpush_getCookie("smpush_device_token"), ""); }; var geoError=function(error){ smpush_debug("Error occurred. Error code: " + error.code); /*0: unknown error, 1: permission denied, 2: position unavailable (error response from location provider), 3: timed out*/ }; navigator.geolocation.getCurrentPosition(geoSuccess); }} function smpushDestroyReqWindow(dismiss){ jQuery("#smart_push_smio_window").remove(); jQuery("#smart_push_smio_overlay").remove(); if(dismiss){ var requestAgainPeriod=1; }else{ var requestAgainPeriod=365; } smpush_setCookie("smpush_desktop_request", "true", requestAgainPeriod); if("0"=="2"&&jQuery("#SMIOPayToReadButton").length > 0&&smpush_getCookie("smpush_device_token")!=""){ location.reload(); }} function smpushHidePopup(){ if("0"=="1"){ smpushDrawUnSupportedPopup(); }else{ smpushDestroyReqWindow(true); }} function smpushDrawNotifyPopup(){ if("0"!="1")return; jQuery("#smart_push_smio_window").remove(); jQuery("#smart_push_smio_overlay").remove(); jQuery("body").append('<style> #smart_push_smio_window{ direction:ltr;display: none;width:600px;max-width: 87%;background-color: white; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; padding: 17px; border-radius: 5px; text-align: center; overflow: hidden; z-index: 99999999; } #smart_push_smio_logo{ border-radius:50%;max-width:150px;max-height:150px;width:50%;height:50%; } #smart_push_smio_msg{ margin-top: 23px;color: #797979; font-size: 18px; text-align: center; font-weight: 300;padding: 0;line-height: normal; } #smart_push_smio_note{ color: #797979; font-size: 15px; text-align: center; font-weight: 300; position: relative; float: none; margin: 16px 0; padding: 0; line-height: normal; } #smart_push_smio_agreement{ color: #9e9e9e; font-size: 13px; text-align: center; font-weight: 300; position: relative; float: none; margin: 16px 0; padding: 0; line-height: normal; } #smart_push_smio_footer{ text-align: center; } #smart_push_smio_not_allow{ background-color: #9E9E9E;text-transform: none; color: white; border: none; box-shadow: none; font-size: 17px; font-weight: 500; -webkit-border-radius: 4px; border-radius: 5px; padding: 10px 32px; margin: 5px; cursor: pointer; } #smart_push_smio_allow{ background-color: #8BC34A;text-transform: none; color: white; border: none; box-shadow: none; font-size: 17px; font-weight: 500; -webkit-border-radius: 4px; border-radius: 5px; padding: 10px 32px; margin: 5px ; cursor: pointer; } </style> <div id="smart_push_smio_overlay" tabindex="-1" style="opacity:0.9; display: none;ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=40); background-color:#000; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 10000;"></div> <div id="smart_push_smio_window" class="smart_push_gdpr_enabled"> <div id="smart_push_smio_close" onclick="smpushDestroyReqWindow(true)" style="display:none!important"></div> <img id="smart_push_smio_logo" src="https://feedarco.com/wp-content/uploads/2022/05/8-dar-28-png-150x150.png" /> <p id="smart_push_smio_msg">اطلاع رسانی سایت</p> <p id="smart_push_smio_note"></p> <p id="smart_push_smio_agreement">با پذیرش این فرم شما می توانید از مطالب جدید و قیمت محصولات مطلع شوید.</p> <div id="smart_push_smio_footer"> <button type="button" onclick="smpushDestroyReqWindow(true)" id="smart_push_smio_not_allow">رد کردن</button> <button type="button" class="smpush-push-permission-button" id="smart_push_smio_allow" disabled>بله می پذیرم</button> </div> </div> '); document.getElementById("smart_push_smio_overlay").style.opacity="0.9"; document.getElementById("smart_push_smio_window").style.position="fixed"; if("1"=="1"){ document.getElementById("smart_push_smio_overlay").style.display="block"; } document.getElementById("smart_push_smio_window").style.display="block"; 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 smpushDrawUnSupportedPopup(){ if("0"!="1")return; jQuery("#smart_push_smio_window").remove(); jQuery("#smart_push_smio_overlay").remove(); jQuery("body").append('<style> #smart_push_smio_window{ direction:ltr;display: none;width:600px;max-width: 87%;background-color: white; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; padding: 17px; border-radius: 5px; text-align: center; overflow: hidden; z-index: 99999999; } #smart_push_smio_logo{ border-radius:50%;max-width:150px;max-height:150px;width:50%;height:50%; } #smart_push_smio_msg{ margin-top: 23px;color: #797979; font-size: 18px; text-align: center; font-weight: 300;padding: 0;line-height: normal; } #smart_push_smio_note{ color: #797979; font-size: 15px; text-align: center; font-weight: 300; position: relative; float: none; margin: 16px 0; padding: 0; line-height: normal; } #smart_push_smio_agreement{ color: #9e9e9e; font-size: 13px; text-align: center; font-weight: 300; position: relative; float: none; margin: 16px 0; padding: 0; line-height: normal; } #smart_push_smio_footer{ text-align: center; } #smart_push_smio_not_allow{ background-color: #9E9E9E;text-transform: none; color: white; border: none; box-shadow: none; font-size: 17px; font-weight: 500; -webkit-border-radius: 4px; border-radius: 5px; padding: 10px 32px; margin: 5px; cursor: pointer; } #smart_push_smio_allow{ background-color: #8BC34A;text-transform: none; color: white; border: none; box-shadow: none; font-size: 17px; font-weight: 500; -webkit-border-radius: 4px; border-radius: 5px; padding: 10px 32px; margin: 5px ; cursor: pointer; } </style> <div id="smart_push_smio_overlay" tabindex="-1" style="opacity:0.9; display: none;ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=40); background-color:#000; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 10000;"></div> <div id="smart_push_smio_window" class="smart_push_gdpr_enabled"> <div id="smart_push_smio_close" onclick="smpushDestroyReqWindow(true)" style="display:none!important"></div> <img id="smart_push_smio_logo" src="https://feedarco.com/wp-content/uploads/2022/05/8-dar-28-png-150x150.png" /> <p id="smart_push_smio_msg">اطلاع رسانی سایت</p> <p id="smart_push_smio_note"></p> <p id="smart_push_smio_agreement">با پذیرش این فرم شما می توانید از مطالب جدید و قیمت محصولات مطلع شوید.</p> <div id="smart_push_smio_footer"> <button type="button" onclick="smpushDestroyReqWindow(true)" id="smart_push_smio_not_allow">رد کردن</button> <button type="button" class="smpush-push-permission-button" id="smart_push_smio_allow" disabled>بله می پذیرم</button> </div> </div> '); document.getElementById("smart_push_smio_overlay").style.opacity="0.9"; document.getElementById("smart_push_smio_window").style.position="fixed"; if("1"=="1"){ document.getElementById("smart_push_smio_overlay").style.display="block"; } document.getElementById("smart_push_smio_window").style.display="block"; 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"; document.getElementById("smart_push_smio_allow").style.display="none"; } function smpushIntializePopupBox(){ jQuery("#smart_push_smio_window").remove(); jQuery("#smart_push_smio_overlay").remove(); jQuery("body").append('<style> #smart_push_smio_window{ direction:ltr;display: none;width:600px;max-width: 87%;background-color: white; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; padding: 17px; border-radius: 5px; text-align: center; overflow: hidden; z-index: 99999999; } #smart_push_smio_logo{ border-radius:50%;max-width:150px;max-height:150px;width:50%;height:50%; } #smart_push_smio_msg{ margin-top: 23px;color: #797979; font-size: 18px; text-align: center; font-weight: 300;padding: 0;line-height: normal; } #smart_push_smio_note{ color: #797979; font-size: 15px; text-align: center; font-weight: 300; position: relative; float: none; margin: 16px 0; padding: 0; line-height: normal; } #smart_push_smio_agreement{ color: #9e9e9e; font-size: 13px; text-align: center; font-weight: 300; position: relative; float: none; margin: 16px 0; padding: 0; line-height: normal; } #smart_push_smio_footer{ text-align: center; } #smart_push_smio_not_allow{ background-color: #9E9E9E;text-transform: none; color: white; border: none; box-shadow: none; font-size: 17px; font-weight: 500; -webkit-border-radius: 4px; border-radius: 5px; padding: 10px 32px; margin: 5px; cursor: pointer; } #smart_push_smio_allow{ background-color: #8BC34A;text-transform: none; color: white; border: none; box-shadow: none; font-size: 17px; font-weight: 500; -webkit-border-radius: 4px; border-radius: 5px; padding: 10px 32px; margin: 5px ; cursor: pointer; } </style> <div id="smart_push_smio_overlay" tabindex="-1" style="opacity:0.9; display: none;ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=40); background-color:#000; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 10000;"></div> <div id="smart_push_smio_window" class="smart_push_gdpr_enabled"> <div id="smart_push_smio_close" onclick="smpushDestroyReqWindow(true)" style="display:none!important"></div> <img id="smart_push_smio_logo" src="https://feedarco.com/wp-content/uploads/2022/05/8-dar-28-png-150x150.png" /> <p id="smart_push_smio_msg">اطلاع رسانی سایت</p> <p id="smart_push_smio_note">دریافت مطالب ، قیمت محصولات به صورت روزانه </p> <p id="smart_push_smio_agreement">با پذیرش این فرم شما می توانید از مطالب جدید و قیمت محصولات مطلع شوید.</p> <div id="smart_push_smio_footer"> <button type="button" onclick="smpushDestroyReqWindow(true)" id="smart_push_smio_not_allow">رد کردن</button> <button type="button" class="smpush-push-permission-button" id="smart_push_smio_allow" disabled>بله می پذیرم</button> </div> </div> '); document.getElementById("smart_push_smio_overlay").style.opacity="0.9"; document.getElementById("smart_push_smio_window").style.position="fixed"; if("1"=="1"){ document.getElementById("smart_push_smio_overlay").style.display="block"; } document.getElementById("smart_push_smio_window").style.display="block"; var position="topcenter"; 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=="bottomright"){ document.getElementById("smart_push_smio_window").style.bottom="10px"; document.getElementById("smart_push_smio_window").style.right="10px"; }else if(position=="bottomleft"){ 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 smpushDrawReqWindow(){ if("native"=="popup"){ smpushIntializePopupBox(); }else if("native"=="subs_page"){ }else{ if("0"=="1"){ jQuery("body").append('<div id="smart_push_smio_overlay" tabindex="-1" style="opacity:0.9; display: block;ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=40); background-color:#000; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 10000;"></div>'); } jQuery("body").append("<button class=\"smpush-push-permission-button\" style=\"display:none\" disabled>بله می پذیرم</button>"); }} function smpushDrawReqIcon(){ if("0"=="1"||smpush_getCookie("smpush_desktop_blocked")=="true"){ jQuery("body").append("<div class=\"tooltip_templates\"><div id=\"smpush_tooltip_gdpr_ver_text\"><img src=\"https://feedarco.com/wp-content/uploads/2022/05/8-dar-28-png-150x150.png\" /><p>برای دریافت ااطلاعات محصولات و نوشته های سایت اعلان سایت را می پذیرم</p><p id=\"smpush_gdpr_hint\">با پذیرش این فرم شما می توانید از مطالب جدید و قیمت محصولات مطلع شوید.</p></div></div>"); jQuery("body").append("<button class=\"smpush-push-permission-button smpush-push-remove-block smpushTooltip\" id=\"smpushIconRequest\" style=\"bottom: 10px; left: 10px;\" data-tooltip-content=\"#smpush_tooltip_gdpr_ver_text\" disabled></button>"); }else if("native"=="icon"||smpush_getCookie("smpush_desktop_blocked")=="true"){ jQuery("body").append("<button class=\"smpush-push-permission-button smpush-push-remove-block smpushTooltip\" id=\"smpushIconRequest\" style=\"bottom: 10px; left: 10px;\" title=\"برای دریافت ااطلاعات محصولات و نوشته های سایت اعلان سایت را می پذیرم\" disabled></button>"); }else{ return; } if("0"=="1"){ jQuery("body").append('<div id="smart_push_smio_overlay" tabindex="-1" style="opacity:0.9; display: block;ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=40); background-color:#000; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 10000;"></div>'); } jQuery("body").append("<style>#smpushIconRequest{display: block;position: fixed;width: 48px;height: 48px;background-color:transparent;background-image: url(https://feedarco.com/wp-content/uploads/2022/05/cropped-Picture7-150x150.png);background-repeat: no-repeat;background-position: center;background-size: 48px 48px;text-indent: -9999px;padding: 0;margin: 0;border: 0;z-index: 999999999;border-radius: 50px;-webkit-border-radius: 50px;-moz-border-radius: 50px;-webkit-box-shadow: 7px 3px 16px 0px rgba(50, 50, 50, 0.2);-moz-box-shadow: 7px 3px 16px 0px rgba(50, 50, 50, 0.2);box-shadow:7px 3px 16px 0px rgba(50, 50, 50, 0.2);}</style>"); smpushTooltip(); jQuery(".smpush-push-remove-block").on("click", function(){ smpush_debug("remove block clicked."); if(smpush_getCookie("smpush_desktop_blocked")=="true"){ smpush_setCookie("smpush_desktop_blocked", "false", -1); }});} function smpush_link_user_cookies(){ if(smpush_getCookie("smpush_fresh_linked_user")!=""&&smpush_getCookie("smpush_linked_user")==""&&smpush_getCookie("smpush_device_token")!=""){ smpush_endpoint_subscribe(smpush_getCookie("smpush_device_token"), ""); smpush_setCookie("smpush_linked_user", "true", 15); smpush_setCookie("smpush_fresh_linked_user", "", -1); }} function smpushWelcomeMSG(){ if(smpush_getCookie("smpush_desktop_welcmsg_seen")=="true"){ return; } if("0"=="1"){ setTimeout(function(){ window.location="https://feedarco.com"; }, 4000); } if("1"=="0"){return;} smpush_setCookie("smpush_desktop_welcmsg_seen", "true", 365); if("safari" in window){ var n=new Notification("پیام خوش آمد گویی !!", { "body": "به وب سایت رادین فیدار فردا خوش آمدید.", "tag":"https://feedarco.com" }); n.onclick=function (){ this.close(); window.open("https://feedarco.com", "_blank"); };}else{ navigator.serviceWorker.ready.then(function(registration){ registration.showNotification("پیام خوش آمد گویی !!", { icon: "https://feedarco.com/wp-content/uploads/2022/05/cropped-Picture7-150x150.png", body: "به وب سایت رادین فیدار فردا خوش آمدید.", tag: "https://feedarco.com", data: {target: "https://feedarco.com"}, requireInteraction: true });});}} function smpush_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 smpush_getCookie(cname){ var name=cname + "="; var ca=document.cookie.split(";"); for(var i=0; i<ca.length; i++){ var c=ca[i]; while (c.charAt(0)==" "){ c=c.substring(1); } if(c.indexOf(name)==0) return c.substring(name.length,c.length); } return ""; } function smpushTooltip(){ jQuery(".smpushTooltip").smiotooltipster({side: "left", contentCloning: true, interactive: true});} if("safari" in window&&"pushNotification" in window.safari){ document.addEventListener("DOMContentLoaded", function(event){ smpush_bootstrap_init(); });}else{ window.addEventListener("load", function(){ smpush_bootstrap_init(); });} function openFBpopup(url, elm){ var new_fbwindow=window.open(url, "", "width=800,height=600"); new_fbwindow.onbeforeunload=function(){ $(elm).hide(); }} "use strict"; if(("0"=="0"||"0"==0)&&("0"=="0"||"0"==0)&&("1"=="0"||"0"=="1")){ window.addEventListener("load", function(){ smpush_debug("manifest registered successfully"); document.getElementsByTagName("HEAD")[0].insertAdjacentHTML("afterbegin", "<link rel=\"manifest\" href=\"https://feedarco.com/?smpushprofile=manifest&version=9.85\">"); });} function smpush_sendSubscriptionToServer(subscriptionId, old_token){ smpush_debug("sending to server...", subscriptionId); smpush_endpoint_subscribe(subscriptionId, old_token); } function smpush_unsubscribe(){ smpush_setCookie("smpush_desktop_request", "true", 10); var pushButton=jQuery(".smpush-push-permission-button"); pushButton.attr("disabled", "disabled"); smpush_getScripts([ "https://www.gstatic.com/firebasejs/7.18.0/firebase-app.js", "https://www.gstatic.com/firebasejs/7.18.0/firebase-messaging.js" ], 0, function (){ var smpush_firebaseConfig=JSON.parse('{"apiKey":"AIzaSyBU2Tuf_2LH-Y3_1TQEJHGUqoo9xCm4l78","authDomain":"feedarco.firebaseapp.com","projectId":"feedarco","storageBucket":"feedarco.appspot.com","messagingSenderId":"609239977917","appId":"1:609239977917:web:180e43ff2c695f61740cd4"}'); const smpushFirebase=firebase.initializeApp(smpush_firebaseConfig, "smpushFirebase"); const smpushMessaging=smpushFirebase.messaging("smpushFirebase"); navigator.serviceWorker.ready.then(function (serviceWorkerRegistration){ smpushMessaging.useServiceWorker(serviceWorkerRegistration); smpushMessaging.getToken().then((currentToken)=> { smpushMessaging.deleteToken(currentToken); smpush_endpoint_unsubscribe(currentToken); smpush_isPushEnabled=false; pushButton.removeAttr("disabled"); pushButton.html("بله می پذیرم"); }).catch(function (e){ smpush_debug("failed unsubscribe...", e); return; });});});} function smpush_getScripts2(scripts, callback){ var progress=0; scripts.forEach(function(script){ jQuery.getScript(script, function (){ if(++progress==scripts.length) callback(); });});} function smpush_getScripts(scripts, cursor, callback){ if(cursor===scripts.length){ callback(); return; } smpush_debug("loaded " + scripts[cursor]); jQuery.getScript(scripts[cursor], function (){ smpush_getScripts(scripts, (cursor+1), callback); });} function smpush_subscribe(){ if(smpush_getCookie("smpush_desktop_blocked")=="true"&&"0"=="0"){ smpush_debug("User unsubscribed using unsubscrib button"); return; } var pushButton=jQuery(".smpush-push-permission-button"); pushButton.attr("disabled","disabled"); if(firebaseInitialized){ smpush_sendSubscriptionToServer(smpush_getCookie("smpush_device_token")); return; } smpush_getScripts([ "https://www.gstatic.com/firebasejs/7.18.0/firebase-app.js", "https://www.gstatic.com/firebasejs/7.18.0/firebase-messaging.js" ], 0, function (){ var smpush_firebaseConfig=JSON.parse('{"apiKey":"AIzaSyBU2Tuf_2LH-Y3_1TQEJHGUqoo9xCm4l78","authDomain":"feedarco.firebaseapp.com","projectId":"feedarco","storageBucket":"feedarco.appspot.com","messagingSenderId":"609239977917","appId":"1:609239977917:web:180e43ff2c695f61740cd4"}'); const smpushFirebase=firebase.initializeApp(smpush_firebaseConfig, "smpushFirebase"); const smpushMessaging=smpushFirebase.messaging("smpushFirebase"); firebaseInitialized=true; navigator.serviceWorker.ready.then(function(serviceWorkerRegistration){ smpushMessaging.useServiceWorker(serviceWorkerRegistration); smpushMessaging.requestPermission().then(function(){ smpush_debug("Notification permission granted."); smpushMessaging.getToken().then((currentToken)=> { if(currentToken){ smpush_debug("Token fetched.", currentToken); smpush_isPushEnabled=true; pushButton.html("خیر نمی پذیرم"); jQuery("#smpushIconRequest").smiotooltipster("content","رد اشتراک در اعلان سایت و پاک کردن اطلاعات ثبت نامی"); pushButton.removeAttr("disabled"); if(smpush_getCookie("smpush_device_token")!=""&&smpush_getCookie("smpush_device_token")!=currentToken){ smpush_sendSubscriptionToServer(currentToken, smpush_getCookie("smpush_device_token")); }else if(smpush_getCookie("smpush_device_token")==""){ smpush_sendSubscriptionToServer(currentToken, ""); }}else{ smpush_debug("No Instance ID token available. Request permission to generate one."); }}).catch((err)=> { smpush_debug("An error occurred while retrieving token. ", err); });}).catch(function(err){ if(Notification.permission==="denied"){ smpush_isPushEnabled=false; smpush_debug("Permission for Notifications is denied"); smpushHidePopup(); pushButton.attr("disabled","disabled"); smpush_endpoint_unsubscribe(smpush_getCookie("smpush_device_token")); }else{ smpush_debug(err); }});smpushMessaging.onMessage((spayload)=> { smpush_debug("Message received. ", spayload); let payload=spayload.notification; if(typeof(payload.command)!="undefined"&&payload.command!=""){ eval(payload.command); } serviceWorkerRegistration.showNotification(payload.title, payload); });smpushMessaging.onTokenRefresh(()=> { smpushMessaging.getToken().then((refreshedToken)=> { smpush_debug("Token refreshed.", refreshedToken); smpush_sendSubscriptionToServer(currentToken, smpush_getCookie("smpush_device_token")); }).catch((err)=> { smpush_debug("Unable to retrieve refreshed token ", err); });});});});} function smpush_initialiseState(){ if(!("showNotification" in ServiceWorkerRegistration.prototype)){ smpush_debug("Notifications aren't supported."); return; } if(Notification.permission==="denied"){ smpushHidePopup(); smpush_debug("The user has blocked notifications."); smpush_endpoint_unsubscribe(smpush_getCookie("smpush_device_token")); return; } if(!("PushManager" in window)){ smpush_debug("Push messaging isn't supported."); return; } jQuery(".smpush-push-permission-button").removeAttr("disabled"); if(Notification.permission==="granted"){ smpush_subscribe(); }else if(Notification.permission==="default"&&"native"=="native"){ smpush_subscribe(); }} function smpushGeko(){ self.addEventListener("notificationclick", function(event){ smpush_debug("notificationclick. ", event); if(typeof(event.notification.data.click)!="undefined"&&event.notification.data.click!=""){ eval(event.notification.data.click); } if(typeof(event.action)!="undefined"&&event.action!=""){ eval(event.notification.data.actions[event.action]); return; } if(event.notification.data.target==""){ return; } event.waitUntil(clients.matchAll({ type: "window" }).then(function(clientList){ for (let i=0; i < clientList.length; i++){ let client=clientList[i]; if(client.url===event.notification.data.target&&"focus" in client){ return client.focus(); }} if(clients.openWindow){ return clients.openWindow(event.notification.data.target); }})); event.notification.close(); });if("serviceWorker" in navigator){ navigator.serviceWorker.register("https://feedarco.com/smart_firebase_sw.js").then(smpush_initialiseState).catch(function(error){ smpush_debug(error); });}else{ smpush_debug("Service workers aren't supported in this browser."); } if(jQuery(".smpush-push-permission-button").length < 1){ return false; } jQuery(".smpush-push-permission-button").on("click", function(){ smpush_debug("clicked.", smpush_isPushEnabled); if(smpush_isPushEnabled){ smpush_unsubscribe(); }else{ smpush_subscribe(); }});jQuery(".smpush-push-subscriptions-button").on("click", function(){ smpush_subscribe(); });} function smpushSafari(){ var pushButton=jQuery(".smpush-push-permission-button"); pushButton.removeAttr("disabled"); if(smpush_getCookie("smpush_safari_device_token")!=""){ pushButton.html("خیر نمی پذیرم"); jQuery("#smpushIconRequest").smiotooltipster("content","رد اشتراک در اعلان سایت و پاک کردن اطلاعات ثبت نامی"); }else{ pushButton.html("بله می پذیرم"); } pushButton.on("click", function(){ var permissionData=window.safari.pushNotification.permission(""); smpushCheckRemotePermission(permissionData); });jQuery(".smpush-push-subscriptions-button").on("click", function(){ var permissionData=window.safari.pushNotification.permission(""); smpushCheckRemotePermission(permissionData); });if("native"=="native"){ document.getElementsByClassName("smpush-push-permission-button")[0].click(); }} var smpushCheckRemotePermission=function (permissionData){ var pushButton=jQuery(".smpush-push-permission-button"); if(permissionData.permission==="default"){ window.safari.pushNotification.requestPermission("https://feedarco.com/push/safari", "", {}, smpushCheckRemotePermission); }else if(permissionData.permission==="denied"){ if(smpush_getCookie("smpush_safari_device_token")!=""){ smpush_endpoint_unsubscribe(smpush_getCookie("smpush_safari_device_token")); } smpush_setCookie("smpush_desktop_request", "true", 10); smpush_setCookie("smpush_safari_device_token", "false", -1); smpush_setCookie("smpush_device_token", "false", -1); smpushHidePopup(); }else if(permissionData.permission==="granted"){ smpushDestroyReqWindow(false); if(smpush_getCookie("smpush_safari_device_token")!=""){ smpush_endpoint_unsubscribe(smpush_getCookie("smpush_safari_device_token")); smpush_setCookie("smpush_desktop_request", "true", 10); smpush_setCookie("smpush_safari_device_token", "false", -1); smpush_setCookie("smpush_device_token", "false", -1); smpush_setCookie("smpush_desktop_welcmsg_seen", "false", -1); pushButton.attr("disabled","disabled"); jQuery(".smpush-push-subscriptions-button").attr("disabled","disabled"); jQuery(".smpush-push-subscriptions-button").html("ذخیر شد"); }else{ if(smpush_getCookie("smpush_safari_device_token")==""){ smpush_setCookie("smpush_safari_device_token", permissionData.deviceToken, 365); smpush_endpoint_subscribe(permissionData.deviceToken, ""); }else{ smpushDestroyReqWindow(false); } pushButton.attr("disabled","disabled"); jQuery(".smpush-push-subscriptions-button").attr("disabled","disabled"); jQuery(".smpush-push-subscriptions-button").html("ذخیر شد"); }} };