psy_vk / js /avp_koleso_v1.js
DmitrMakeev's picture
Update js/avp_koleso_v1.js
4f47adf verified
raw
history blame
3.88 kB
!function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t){var o,n,r,l=window.avp,a=Number(window.grup),i=window.new_w,c=window.red_url,d=(window.hook,window.sector),u=window.idSpun,s=window.delay,f=window.but_text,p=window.color_but;d&&Array.isArray(d)||(console.error("Sectors is not defined or not an array"),d=[]),vkBridge.send("VKWebAppInit"),vkBridge.send("VKWebAppAllowMessagesFromGroup",{group_id:a,key:"cc964fabb0e1d70924a92e4e8b513dbff7cc10a9"}).then(e=>{if(e.result)return vkBridge.send("VKWebAppGetUserInfo");throw new Error("User did not allow messages from group")}).then(e=>{n=e.id,e.id,e.photo_100,r=location.hash}).catch(e=>{console.error("Error:",e),window.location.href=c});const w=d.length,h=document.querySelector("#spin"),b=document.querySelector("#wheel").getContext("2d"),m=b.canvas.width/2,y=Math.PI,g=2*y,v=g/d.length;let S=0,k=0;const x=()=>Math.floor(w-k/g*w)%w;function E(e,t){const o=v*t;b.save(),b.beginPath(),b.fillStyle=e.color,b.moveTo(m,m),b.arc(m,m,m,o,o+v),b.lineTo(m,m),b.fill(),b.translate(m,m),b.rotate(o+v/2),b.textAlign="right",b.fillStyle="#fff",b.font="bold 21px sans-serif",b.fillText(e.label,m-10,10),b.restore()}function _(){const e=d[x()];b.canvas.style.transform=`rotate(${k-y/2}rad)`,h.textContent=S?e.label:f,h.style.background=p}function I(){if(S){if(S*=.991,S<.002){S=0;const e=d[x()];localStorage.setItem(u,"true"),setTimeout(()=>{!function(e){o=e;const t=document.getElementById("formKol"),n=document.getElementById("registrationForm");document.getElementById("bonusValue").textContent=o,t.style.display="none",n.style.display="block"}(e.label)},s)}k+=S,k%=g,_()}}function A(){I(),requestAnimationFrame(A)}window.onload=function(){localStorage.getItem(u)||localStorage.setItem(u,"false"),d.forEach(E),_(),A(),h.addEventListener("click",()=>{var e,t;"false"===localStorage.getItem(u)?(localStorage.setItem(u,"true"),e=.25,t=.45,S=Math.random()*(t-e)+e,function(){const e=d.map(e=>e.probability).reduce((e,t)=>e+t,0),t=Math.random()*e;let o=0;for(let e=0;e<d.length;e++)if(o+=d[e].probability,t<o){k=(e+.5)*v;break}}()):console.log("You have already spun the wheel.")})},document.getElementById("contactForm").addEventListener("submit",(function(e){e.preventDefault();const t=e.target,a=new FormData;t.querySelectorAll("input, textarea").forEach(e=>{("radio"!==e.type||e.checked)&&a.append(e.id,e.value)}),t.querySelectorAll('input[type="checkbox"]').forEach(e=>{a.append(e.id,e.checked)});const c=new URLSearchParams(a).toString();console.log("Данные для отправки:",c);const d="https://skyauto.me/cllbck/"+l+"?api=1&uid="+n+"&hash="+r+"&bohus="+o;console.log("secondServerURL:",d),fetch(d,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:c}).then(e=>{if(!e.ok)throw new Error("Ошибка HTTP: "+e.status);return e.json()}).then(e=>{console.log("Данные от сервера:",e),e.redirect&&(i?window.open(e.redirect,"_blank"):window.location.href=e.redirect)}).catch(e=>{console.error("Error:",e)})}))}]);