File size: 4,004 Bytes
a2107af
1
!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=window.avp,r=Number(window.grup),l=window.new_w,a=window.red_url,i=(window.hook,window.sector),c=window.idSpun,d=window.delay,u=window.but_text,s=window.color_but;const f=window.sound_r,p=window.sound_s;let w=new Audio(f),h=new Audio(p);var m,y;i&&Array.isArray(i)||(console.error("Sectors is not defined or not an array"),i=[]),vkBridge.send("VKWebAppInit"),vkBridge.send("VKWebAppAllowMessagesFromGroup",{group_id:r,key:"cc964fabb0e1d70924a92e4e8b513dbff7cc10a9"}).then(e=>{if(e.result)return vkBridge.send("VKWebAppGetUserInfo");throw new Error("User did not allow messages from group")}).then(e=>{m=e.id,e.id,e.photo_100,y=location.hash}).catch(e=>{console.error("Error:",e),window.location.href=a});const b=i.length,g=document.querySelector("#spin"),v=document.querySelector("#wheel").getContext("2d"),S=v.canvas.width/2,k=Math.PI,x=2*k,_=x/i.length;let E=0,A=0;const I=()=>Math.floor(b-A/x*b)%b;function T(e,t){const o=_*t;v.save(),v.beginPath(),v.fillStyle=e.color,v.moveTo(S,S),v.arc(S,S,S,o,o+_),v.lineTo(S,S),v.fill(),v.translate(S,S),v.rotate(o+_/2),v.textAlign="right",v.fillStyle="#fff",v.font="bold 21px sans-serif",v.fillText(e.label,S-10,10),v.restore()}function P(){const e=i[I()];v.canvas.style.transform=`rotate(${A-k/2}rad)`,g.textContent=E?e.label:u,g.style.background=s}function M(){if(E){if(E*=.991,E<.002){E=0;const e=i[I()];localStorage.setItem(c,"true"),w.pause(),w.currentTime=0,h.play(),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)},d)}A+=E,A%=x,P()}}function j(){M(),requestAnimationFrame(j)}window.onload=function(){localStorage.getItem(c)||localStorage.setItem(c,"false"),i.forEach(T),P(),j(),g.addEventListener("click",()=>{var e,t;"false"===localStorage.getItem(c)?(localStorage.setItem(c,"true"),e=.25,t=.45,E=Math.random()*(t-e)+e,function(){const e=i.map(e=>e.probability).reduce((e,t)=>e+t,0),t=Math.random()*e;let o=0;for(let e=0;e<i.length;e++)if(o+=i[e].probability,t<o){A=(e+.5)*_;break}w.play()}()):console.log("You have already spun the wheel.")})},document.getElementById("contactForm").addEventListener("submit",(function(e){e.preventDefault();const t=e.target,r=new FormData;t.querySelectorAll("input, textarea").forEach(e=>{("radio"!==e.type||e.checked)&&r.append(e.id,e.value)}),t.querySelectorAll('input[type="checkbox"]').forEach(e=>{r.append(e.id,e.checked)});const a=new URLSearchParams(r).toString();console.log("Данные для отправки:",a);const i="https://skyauto.me/cllbck/"+n+"?api=1&uid="+m+"&hash="+y+"&bohus="+o;console.log("secondServerURL:",i),fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a}).then(e=>{if(!e.ok)throw new Error("Ошибка HTTP: "+e.status);return e.json()}).then(e=>{console.log("Данные от сервера:",e),e.redirect&&(l?window.open(e.redirect,"_blank"):window.location.href=e.redirect)}).catch(e=>{console.error("Error:",e)})}))}]);