-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path397c23d8d6ca0b67ce26.js
1 lines (1 loc) · 3.32 KB
/
397c23d8d6ca0b67ce26.js
1
!function(){"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),function(){var t;e.g.importScripts&&(t=e.g.location+"");var n=e.g.document;if(!t&&n&&(n.currentScript&&"SCRIPT"===n.currentScript.tagName.toUpperCase()&&(t=n.currentScript.src),!t)){var o=n.getElementsByTagName("script");if(o.length)for(var i=o.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=o[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t}();const t=e=>sessionStorage.getItem(e)??0,n=document.querySelector(".player-one-score"),o=document.querySelector(".player-two-score"),i=(e,t)=>e.textContent=t,r=(e,t)=>e[t],s=(e="10")=>e,l=document.querySelector(".field__ball"),c=e=>{let t="left"===e?`${s()}px`:r(document.documentElement,"clientWidth")-r(l,"width")-s()+"px";l.style.left=t},a=e=>{let t="top"===e?`${s()}px`:(()=>{let e=+s(),t=Math.floor(r(document.documentElement,"clientHeight")-r(l,"width")-e);return Math.floor(Math.random()*(t-e+1)+e)})()+"px";l.style.top=t},h=e=>new Promise((t=>setTimeout(t,e))),m=()=>{const e=t("flag");h(50).then((()=>l.style.transition="none")),h(300).then((()=>l.style.transition="all 0.6s ease-in")),a("top"),c("0"===e?"left":"right")},d=document.querySelector(".field-orientation__message"),p=document.querySelector(".field__img"),u=document.querySelector(".field__portrait-image"),g=e=>{p.classList[e]("field__img_hide"),u.classList[e]("field__portrait-image_show"),d.classList[e]("field-orientation__message_show")},f=()=>{window.matchMedia("(orientation: portrait)").matches?g("add"):g("remove")},y=(e,t)=>sessionStorage.setItem(e,t);var w=e.p+"assets/sounds/114fe0db7b845040846d.mp3";const S=e=>new Audio(e).play(),_=()=>parseInt(r(p,"height")/2)-r(l,"width")/2,b=[{min:540,height:175},{min:520,height:164},{min:500,height:157},{min:470,height:145},{min:446,height:137},{min:420,height:127},{min:388,height:116},{min:360,height:106},{min:332,height:100},{min:300,height:84},{min:282,height:78},{min:261.5,height:76},{min:246.5,height:73},{min:223.5,height:68},{min:208.5,height:62},{min:0,height:40}],v=()=>{const e=_();for(const t of b)if(e>=t.min)return t.height};var E=e.p+"assets/sounds/332ce99164b12276bdac.mp3",T=e.p+"assets/sounds/b869d22e2064c02c8cf7.mp3";const x=(e,t)=>{var n;parseInt(l.style.top)<=_()+v()&&parseInt(l.style.top)>=_()-v()&&(h(200).then(S(T)),h(700).then((()=>{S(E),e.textContent++,y(t,e.textContent),a("top")})),n=e,h(700).then((()=>n.style.color="#ff0000")),h(1600).then((()=>n.style.color="#e4ff00")))};let q=0;const I=(e,t,n,o)=>{S(w),a("random"),c(e),x(t,n),q=o,y("flag",q)},L={".field__restart-btn":()=>{y("playerOneScore",0),y("playerTwoScore",0),i(n,t("playerOneScore")),i(o,t("playerTwoScore"))},".fullscreen-toggle":()=>{const e=document.documentElement;document.fullscreenElement?document.exitFullscreen():e.requestFullscreen()},".field__ball":()=>{"0"===t("flag")?I("right",n,"playerOneScore",1):I("left",o,"playerTwoScore",0)}};window.addEventListener("resize",(()=>{m(),f()})),window.addEventListener("load",(()=>{f(),m(),i(n,t("playerOneScore")),i(o,t("playerTwoScore"))})),window.addEventListener("click",(e=>{((e,t)=>{const n=e.target;for(const o in t)if(n.closest(o)){t[o](e);break}})(e,L)}))}();