psy_vk / js /senler_form_v1.js
DmitrMakeev's picture
Update js/senler_form_v1.js
d26cf20 verified
raw
history blame
7.78 kB
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t){const n=window.w_url.replace(/\/+$/,"")+"/add_user_senler_full",o=window.w_url.replace(/\/+$/,"")+"/get_Lo_Mess_senler",a=window.w_url.replace(/\/+$/,"")+"/del_user_senler",r=Number(window.vk_grup),l=window.vk_grup,s=window.s_grup,d=window.red_on,c=window.on_url,i=window.clarity_on,p=window.clarity_id,u=window.clarity_ses,m=window.clarity_tar,y=window.funnel,w=window.clarity_ev,g=window.ups;let _,f,h,k,B,b,P,E,v,I;const S=new URL(window.location.href),T=S.searchParams.get("vk_user_id");S.searchParams.get("vk_app_id"),window.location.href;I=window.location.hash.substring(1);const x=new URLSearchParams(I);k=x.get("gcpc")||"",B=x.get("utm_source")||"",b=x.get("utm_medium")||"",P=x.get("utm_campaign")||"",E=x.get("utm_content")||"",v=x.get("utm_term")||"";const L=T.toString();S.searchParams.get("vk_app_id");let j;function O(){document.getElementById("formBlock").style.display="none",document.getElementById("loyaltyBlock").style.display="block",i&&(window.clarity?window.clarity("set","loyalty","not"):console.log("Clarity is not initialized"))}function U(){_=document.getElementById("name").value,f=document.getElementById("email").value,h=document.getElementById("phone").value;const e=new URLSearchParams;e.append("vk_user_id",j),e.append("vk_group_id",l),e.append("sub_id",s),e.append("name",_),e.append("email",f),e.append("phone",h),e.append("utm_source",B),e.append("utm_medium",b),e.append("utm_campaign",P),e.append("utm_content",E),e.append("utm_term",v),fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e.toString()}).then(e=>{if(!e.ok)throw new Error("Ошибка HTTP: "+e.status);return e.json()}).then(e=>{if(console.log("Данные от сервера:",e),e&&e.add_response&&e.add_response.success&&e.add_response.subscribers&&e.add_response.subscribers[0]&&e.add_response.subscribers[0].success)if(document.getElementById("formBlock").style.display="none",document.getElementById("loyaltyBlock").style.display="none",document.getElementById("loaderBlock").style.display="none",document.getElementById("thankBlock").style.display="block",document.getElementById("stopBlock").style.display="block",d){i&&(R(w),C());let e=new URL(c);e.searchParams.append("ups",g),e.searchParams.append("name",_),e.searchParams.append("email",f),e.searchParams.append("phone",h),e.searchParams.append("uid",j),e.searchParams.append("gcpc",k),e.searchParams.append("utm_source",B),e.searchParams.append("utm_medium",b),e.searchParams.append("utm_campaign",P),e.searchParams.append("utm_content",E),e.searchParams.append("utm_term",v),window.open(e.toString(),"_blank")}else i&&(R(w),C(),document.getElementById("loaderBlock").style.display="none");else console.error("Ошибка при добавлении пользователя:",e)}).catch(e=>{console.error("Error:",e)})}function R(e){window.clarity?window.clarity("event",e):console.log("Clarity is not initialized")}function C(){window.clarity?window.clarity("set","loyalty","yes"):console.log("Clarity is not initialized")}var M,z,A,D,q,H,K;vkBridge.send("VKWebAppInit"),document.getElementById("contactForm").addEventListener("submit",(function(e){e.preventDefault(),vkBridge.send("VKWebAppAllowMessagesFromGroup",{group_id:r,key:"cc964fabb0e1d70924a92e4e8b513dbff7cc10a9"}).then(e=>{e.result?vkBridge.send("VKWebAppGetUserInfo").then(e=>{j=e.id,document.getElementById("loaderBlock").style.display="flex",C(),setTimeout(U,1e3)}).catch(e=>{O()}):O()}).catch(e=>{O()})})),i&&(M=window,z=document,D="script",q=p,M[A="clarity"]=M[A]||function(){(M[A].q=M[A].q||[]).push(arguments)},(H=z.createElement(D)).async=1,H.src="https://www.clarity.ms/tag/"+q,(K=z.getElementsByTagName(D)[0]).parentNode.insertBefore(H,K),function(e,t,n){window.clarity?window.clarity("identify",e,t,n):console.log("Clarity is not initialized")}(L,u,m),function(e,t,n,o,a,r){window.clarity?(window.clarity("set","utm_source",e),window.clarity("set","utm_medium",t),window.clarity("set","utm_campaign",n),window.clarity("set","utm_content",o),window.clarity("set","utm_term",a),window.clarity("set","funnel",r)):console.log("Clarity is not initialized")}(B,b,P,E,v,y)),$(document).ready((function(){$("#linkThank").on("click",(function(e){if(e.preventDefault(),d){let e=new URL($(this).attr("href"));e.searchParams.append("ups",g),e.searchParams.append("name",_),e.searchParams.append("email",f),e.searchParams.append("phone",h),e.searchParams.append("uid",j),e.searchParams.append("gcpc",k),e.searchParams.append("utm_source",B),e.searchParams.append("utm_medium",b),e.searchParams.append("utm_campaign",P),e.searchParams.append("utm_content",E),e.searchParams.append("utm_term",v),window.open(e.toString(),"_blank")}else window.open($(this).attr("href"),"_blank")})),function(){const e=new URLSearchParams;e.append("vk_user_id",T),e.append("vk_group_id",l),e.append("sub_id",s),document.getElementById("loaderBlock").style.display="flex",fetch(o,{method:"POST",body:e}).then(e=>{if(!e.ok)throw new Error("Ошибка HTTP: "+e.status);return e.json()}).then(e=>{e&&"1"===e.status?(document.getElementById("formBlock").style.display="none",document.getElementById("thankBlock").style.display="block",document.getElementById("stopBlock").style.display="block",document.getElementById("loaderBlock").style.display="none",console.log("Есть подписка")):(document.getElementById("formBlock").style.display="block",document.getElementById("loaderBlock").style.display="none",console.log("Нет подписки"))}).catch(e=>{console.error("Error:",e)})}(),$("#linkStopBlock").on("click",(function(e){e.preventDefault(),function(){const e=new URLSearchParams;e.append("vk_user_id",T),e.append("vk_group_id",l),e.append("sub_id",s),document.getElementById("loaderBlock").style.display="flex",fetch(a,{method:"POST",body:e}).then(e=>{if(!e.ok)throw new Error("Ошибка HTTP: "+e.status);return e.json()}).then(e=>{console.log("Ответ от сервера:",e),e&&"success"===e.status?(document.getElementById("formBlock").style.display="block",document.getElementById("stopBlock").style.display="none",document.getElementById("thankBlock").style.display="none",document.getElementById("loaderBlock").style.display="none",console.log("Подписка отменена")):console.log("Ошибка или подписка не отменена")}).catch(e=>{console.error("Error:",e)})}()}))})),i&&(document.addEventListener("copy",(function(e){console.log("Текст скопирован:",window.getSelection().toString()),window.clarity&&window.clarity("set","text_copy","yes")})),document.querySelectorAll("img").forEach(e=>{e.addEventListener("contextmenu",(function(e){console.log("Контекстное меню открыто на изображении:",e.target.src),e.preventDefault(),window.clarity&&window.clarity("set","img_save","yes")}))}))}]);