psy_vk / js /avp_kol_vk_sav.js
DmitrMakeev's picture
Update js/avp_kol_vk_sav.js
5a2b09a verified
raw
history blame
4.23 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=window.avp,r=Number(window.grup),a=window.new_w,l=window.red_url,i=(window.hook,window.sector),c=window.idSpun,d=window.delay,s=window.but_text,u=window.color_but;const f=window.sound_r,p=window.sound_s;let y=new Audio(f),h=new Audio(p);var w,b;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=>{w=e.id,e.id,e.photo_100,b=location.hash}).catch(e=>{console.error("Error:",e),window.location.href=l});const g=i.length,m=document.querySelector("#spin"),v=document.querySelector("#wheel").getContext("2d"),k=v.canvas.width/2,S=Math.PI,x=2*S,A=x/i.length;let E=0,_=0;const T=()=>Math.floor(g-_/x*g)%g;function B(e,t){const o=A*t;v.save(),v.beginPath(),v.fillStyle=e.color,v.moveTo(k,k),v.arc(k,k,k,o,o+A),v.lineTo(k,k),v.fill(),v.translate(k,k),v.rotate(o+A/2),v.textAlign="right",v.fillStyle="#fff",v.font="bold 21px sans-serif",v.fillText(e.label,k-10,10),v.restore()}function P(){const e=i[T()];v.canvas.style.transform=`rotate(${_-S/2}rad)`,m.textContent=E?e.label:s,m.style.background=u}function M(){if(E){if(E*=.991,E<.002){E=0;const o=i[T()];e=c,t=o.label,vkBridge.send("VKWebAppStorageSet",{key:e,value:t}),y.pause(),y.currentTime=0,h.play(),setTimeout(()=>{K(o.label)},d)}var e,t;_+=E,_%=x,P()}}function j(){M(),requestAnimationFrame(j)}function K(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"}vkBridge.send("VKWebAppStorageGet",{keys:[c]}).then(e=>{const t=e.keys.length>0?e.keys[0].value:"";""!==t?K(t):(i.forEach(B),P(),j(),m.addEventListener("click",()=>{vkBridge.send("VKWebAppStorageGet",{keys:[c]}).then(e=>{var t,o;""===(e.keys.length>0?e.keys[0].value:"")?(t=.25,o=.45,E=Math.random()*(o-t)+t,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){_=(e+.5)*A;break}y.play()}()):console.log("You have already spun the wheel.")}).catch(e=>{console.error("Error getting data from VK storage:",e)})}))}).catch(e=>{console.error("Error initializing:",e)}),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 l=new URLSearchParams(r).toString();console.log("Данные для отправки:",l);const i="https://skyauto.me/cllbck/"+n+"?api=1&uid="+w+"&hash="+b+"&bohus="+o;console.log("secondServerURL:",i),fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:l}).then(e=>{if(!e.ok)throw new Error("Ошибка HTTP: "+e.status);return e.json()}).then(e=>{console.log("Данные от сервера:",e),e.redirect&&(a?window.open(e.redirect,"_blank"):window.location.href=e.redirect)}).catch(e=>{console.error("Error:",e)})}))}]);