Files
ToneAPI_webclient/dist/js/app.9c5f7aa2.js
T
2023-03-28 22:21:06 +02:00

2 lines
14 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(){"use strict";var e={9111:function(e,t,s){var r=s(9242),a=s(3396);const l=(0,a.uE)('<div class="navbar-element">TONE API</div><div class="navbar-element"><a href="https://github.com/Legonzaur/Tone_WebClient">Github</a></div><div class="navbar-element"><a href="https://github.com/Legonzaur/ToneAPI_servermod">Northstar Server Mod</a></div><div class="spacer"></div>',4);function i(e,t){const s=(0,a.up)("router-link"),r=(0,a.up)("router-view");return(0,a.wg)(),(0,a.iD)(a.HY,null,[(0,a._)("header",null,[(0,a._)("nav",null,[l,(0,a.Wm)(s,{to:"/",class:"navbar-element"},{default:(0,a.w5)((()=>[(0,a.Uk)("Players")])),_:1})])]),(0,a.Wm)(r)],64)}var n=s(89);const o={},d=(0,n.Z)(o,[["render",i]]);var c=d,h=s(2483);const p={id:"filters"},u={id:"playerView"};function y(e,t,s,r,l,i){const n=(0,a.up)("VueMultiselect"),o=(0,a.up)("PlayerList"),d=(0,a.up)("PlayerChart");return(0,a.wg)(),(0,a.iD)(a.HY,null,[(0,a._)("div",p,[(0,a.Wm)(n,{showLabels:!1,placeholder:"Select server",modelValue:e.models.server,"onUpdate:modelValue":t[0]||(t[0]=t=>e.models.server=t),options:e.servers,"allow-empty":!0,"custom-label":e=>e.name,onSelect:t[1]||(t[1]=t=>e.changeFilter({server:t.id})),onRemove:t[2]||(t[2]=t=>e.changeFilter({server:""}))},null,8,["modelValue","options","custom-label"]),(0,a.Wm)(n,{showLabels:!1,selectLabel:"",placeholder:"Select weapon",modelValue:e.models.weapon,"onUpdate:modelValue":t[3]||(t[3]=t=>e.models.weapon=t),options:e.sortedWeaponList,"allow-empty":!0,onSelect:t[4]||(t[4]=t=>e.changeFilter({weapon:t})),onRemove:t[5]||(t[5]=t=>e.changeFilter({weapon:""}))},null,8,["modelValue","options"]),(0,a.Wm)(n,{showLabels:!1,selectLabel:"",placeholder:"Search player",modelValue:e.playerHighlighted,"onUpdate:modelValue":t[6]||(t[6]=t=>e.playerHighlighted=t),options:e.sortedPlayerList,"allow-empty":!0,"custom-label":t=>e.players[t]?.username},null,8,["modelValue","options","custom-label"])]),(0,a._)("div",u,[(0,a.Wm)(o,{filters:e.filters,onHighlightPlayer:t[7]||(t[7]=t=>e.playerHighlighted=t),playerHighlighted:e.playerHighlighted},null,8,["filters","playerHighlighted"]),(0,a.Wm)(d,{filters:e.filters,onHighlightPlayer:t[8]||(t[8]=t=>e.playerHighlighted=t),playerHighlighted:e.playerHighlighted},null,8,["filters","playerHighlighted"])])],64)}s(7658);var g=s(65),f=s(7139);const m=e=>((0,a.dD)("data-v-227422ef"),e=e(),(0,a.Cn)(),e),v={class:"playerHeaders"},b=m((()=>(0,a._)("span",null,null,-1))),w=["onClick"];function _(e,t,s,r,l,i){return(0,a.wg)(),(0,a.iD)("div",{class:"playerTable",onKeydown:t[6]||(t[6]=(...t)=>e.selectNextPlayer&&e.selectNextPlayer(...t)),tabindex:"0"},[(0,a._)("div",v,[b,(0,a._)("span",{onClick:t[0]||(t[0]=t=>e.sortPlayerList("username")),class:(0,f.C_)("username"==e.sortingData.argument?"selected":"")},"Username",2),(0,a._)("span",{onClick:t[1]||(t[1]=t=>e.sortPlayerList("kills")),class:(0,f.C_)("kills"==e.sortingData.argument?"selected":"")},"K",2),(0,a._)("span",{onClick:t[2]||(t[2]=t=>e.sortPlayerList("deaths")),class:(0,f.C_)("deaths"==e.sortingData.argument?"selected":"")},"D",2),(0,a._)("span",{onClick:t[3]||(t[3]=t=>e.sortPlayerList("k/d")),class:(0,f.C_)("k/d"==e.sortingData.argument?"selected":"")},"K/D",2),(0,a._)("span",{onClick:t[4]||(t[4]=t=>e.sortPlayerList("max_kill_distance")),class:(0,f.C_)("max_kill_distance"==e.sortingData.argument?"selected":"")},"max distance",2),(0,a._)("span",{onClick:t[5]||(t[5]=t=>e.sortPlayerList("avg_kill_distance")),class:(0,f.C_)("avg_kill_distance"==e.sortingData.argument?"selected":"")},"average distance",2)]),((0,a.wg)(!0),(0,a.iD)(a.HY,null,(0,a.Ko)(e.playerIdList,((t,s)=>((0,a.wg)(),(0,a.iD)("div",{class:"playerRow",key:t,onClick:s=>e.$emit("highlightPlayer",t),ref_for:!0,ref:"player:"+t},[(0,a._)("div",null,[(0,a._)("span",null,(0,f.zw)(s),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,f.zw)(e.players[t].username),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,f.zw)(e.players[t].kills),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,f.zw)(e.players[t].deaths),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,f.zw)(Math.round(e.players[t].kills/e.players[t].deaths*100)/100),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,f.zw)(e.players[t].max_kill_distance),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,f.zw)(Math.round(100*e.players[t].avg_kill_distance)/100),1)])],8,w)))),128))],32)}var k=(0,a.aZ)({props:{filters:Object,playerHighlighted:String},emits:["highlightPlayer"],data(){return{sortingData:{direction:-1,argument:"kills"},playerIdList:[],store:(0,g.oR)(),selected:void 0}},computed:{players(){return this.store.getters.getPlayerList(this.filters)}},watch:{players:{handler(e){e&&(this.playerIdList=[],this.sortingData.direction*=-1,this.playerIdList=Object.keys(e),this.sortPlayerList(this.sortingData.argument),this.$nextTick((()=>{const e=this.$refs["player:"+this.selected];e&&e.length>0&&e[0].classList.add("selected")})))},immediate:!0},playerHighlighted(e,t){const s=this.$refs["player:"+t];s&&(s[0].classList.remove("selected"),delete this.selected);const r=this.$refs["player:"+e];r&&(r[0].classList.add("selected"),r[0].scrollIntoView({behavior:"smooth",block:"center"}),this.selected=e)}},updated(){const e=this.$refs["player:"+this.$props.playerHighlighted];e&&e[0]&&e[0].scrollIntoView({behavior:"smooth",block:"center"})},methods:{sortPlayerList(e){e===this.sortingData.argument?this.sortingData.direction*=-1:"username"===e&&(this.sortingData.direction=1),this.sortingData.argument=e,this.playerIdList.sort(((t,s)=>{if(!this.players)return 0;let r,a;return"k/d"===e?(r=this.players[t].kills/this.players[t].deaths,a=this.players[s].kills/this.players[s].deaths):(r=this.players[t][e],a=this.players[s][e]),r<a?-1*this.sortingData.direction:r>a?1*this.sortingData.direction:0}))},selectNextPlayer(e){const t={Home:-1/0,End:1/0,PageDown:100,PageUp:-100,ArrowUp:-1,ArrowDown:1,ArrowRight:10,ArrowLeft:-10};if(!this.selected)return;if(!Object.keys(t).includes(e.key))return;e.preventDefault();const s=this.playerIdList.indexOf(this.selected);let r=s+t[e.key];r>=this.playerIdList.length&&(r=this.playerIdList.length-1),r<0&&(r=0),this.$emit("highlightPlayer",this.playerIdList[r])}}});const L=(0,n.Z)(k,[["render",_],["__scopeId","data-v-227422ef"]]);var P=L;const C={class:"playerChart",ref:"container"};function x(e,t,s,r,l,i){const n=(0,a.up)("Scatter");return(0,a.wg)(),(0,a.iD)("div",C,[(0,a.Wm)(n,{data:e.chart,options:e.chartOptions},null,8,["data","options"])],512)}var O=s(3254),D=s(9152),I=s(3013),H=s(5866);O.kL.register(O.f$,O.od,O.jn,O.u,O.De,D.Z,I.Z);var S=(0,a.aZ)({name:"PlayerChart",props:{filters:Object,playerHighlighted:String},emits:["highlightPlayer"],components:{Scatter:H.bp},mounted(){this.refreshColors++},computed:{colors(){this.refreshColors;const e={};if(this.$refs.container){const t=getComputedStyle(this.$refs.container);e.fg=t.getPropertyValue("--foreground"),e.bg=t.getPropertyValue("--bg-color"),e.orange=t.getPropertyValue("--orange"),e.cyan=t.getPropertyValue("--cyan"),e.currentLine=t.getPropertyValue("--current-line")}else e.fg="#ffffff";return e},chart(){const e={datasets:[{label:"Players",labels:[],borderColor:[this.colors.fg],backgroundColor:[this.colors.fg],pointRadius:[1],pointStyle:["dot"],hoverRadius:[4],data:[]}]};if(!this.players)return e;if(e.datasets[0].labels=this.playerIdList,e.datasets[0].data=this.playerIdList.map((e=>this.players?{x:this.players[e].deaths,y:this.players[e].kills}:{x:0,y:0})),e.datasets[0].pointRadius=Array(e.datasets[0].labels.length).fill(1),e.datasets[0].pointStyle=Array(e.datasets[0].labels.length).fill("dot"),e.datasets[0].borderColor=Array(e.datasets[0].labels.length).fill(this.colors.cyan),e.datasets[0].backgroundColor=e.datasets[0].borderColor,e.datasets[0].hoverRadius=Array(e.datasets[0].labels.length).fill(4),this.$props.playerHighlighted){const t=this.playerIdList.indexOf(this.$props.playerHighlighted);e.datasets[0].pointRadius[t]=20,e.datasets[0].pointStyle[t]="crossRot",e.datasets[0].borderColor[t]=this.colors.orange,e.datasets[0].hoverRadius[t]=30}return e},chartOptions(){const e={responsive:!0,maintainAspectRatio:!0,animation:{duration:500},layout:{autoPadding:!1},scales:{y:{title:{text:"Kills",display:!0,color:this.colors.fg},ticks:{color:this.colors.fg}},x:{title:{text:"Deaths",display:!0,color:this.colors.fg},ticks:{color:this.colors.fg}}},plugins:{tooltip:{callbacks:{label:e=>{let t;return t=this.players?this.players[e.dataset.labels[e.dataIndex]].username:e.dataset.labels[e.dataIndex],t+=" ("+e.parsed.y+" kills "+e.parsed.x+" deaths)",t}}},annotation:{},legend:{display:!1},datalabels:{formatter:(e,t)=>this.players[this.playerIdList[t.dataIndex]].username,backgroundColor:Array(this.playerIdList.length).fill(null),borderColor:this.colors.fg,borderWidth:Array(this.playerIdList.length).fill(0),borderRadius:5,display:Array(this.playerIdList.length).fill("auto"),align:"-45",anchor:"end",clamp:!0,color:Array(this.playerIdList.length).fill(this.colors.fg)}},onClick:(e,t)=>{this.$emit("highlightPlayer",t.length>0?this.playerIdList[t[0].index]:void 0)},onHover:(e,t)=>{e.native.target&&(e.native.target.style.cursor=t[0]?"pointer":"default")}};if(!this.players)return e;const t=Math.max(...Object.values(this.players).map((e=>e.deaths))),s=Math.max(...Object.values(this.players).map((e=>e.kills)));let r,a;if(s>t?(r=t,a=t/s*s):(a=s,r=s/t*t),e.plugins.annotation={annotations:{line:{type:"line",yMin:0,xMin:0,yMax:a,xMax:r,borderWidth:2,borderColor:this.colors.orange,borderDash:[1,5]}}},this.$props.playerHighlighted){const t=this.playerIdList.indexOf(this.$props.playerHighlighted);e.plugins.datalabels.display[t]=!0,e.plugins.datalabels.backgroundColor[t]=this.colors.orange,e.plugins.datalabels.borderWidth[t]=1,e.plugins.datalabels.color[t]=this.colors.bg}return e},players(){return this.store.getters.getPlayerList(this.filters)||{}},playerIdList(){return Object.keys(this.players)}},data(){return{store:(0,g.oR)(),refreshColors:0}}});const j=(0,n.Z)(S,[["render",x],["__scopeId","data-v-cf8f72c6"]]);var W=j,V=s(6368),R=(0,a.aZ)({name:"PlayerView",components:{PlayerList:P,PlayerChart:W,VueMultiselect:V.ZP},data(){return{models:{},filters:{minKills:100,minDeaths:100},store:(0,g.oR)(),playerHighlighted:void 0}},computed:{servers(){return this.store.state.servers},weapons(){return this.store.getters.getWeaponList(this.filters)},sortedWeaponList(){if(!this.weapons)return[];const e=Object.keys(this.weapons);return e.sort()},players(){return this.store.getters.getPlayerList(this.filters)},sortedPlayerList(){if(!this.players)return[];const e=Object.keys(this.players);return e.sort(((e,t)=>this.players?this.players[e].username<this.players[t].username?-1:this.players[e].username>this.players[t].username?1:0:0))}},watch:{test:function(e){console.log(e)}},methods:{async changeFilter({weapon:e,server:t}){console.log(e);const s=JSON.parse(JSON.stringify(this.filters));void 0!==e&&(s.weapon=e),void 0!==t&&(s.server=t),""===e&&delete s.weapon,""===t&&delete s.server;const r=[];this.store.getters.getPlayerList(s)||r.push(this.store.dispatch("fetchPlayers",s)),this.store.getters.getWeaponList(s)||r.push(this.store.dispatch("fetchWeapons",s)),await Promise.all(r),this.filters=s}}});const $=(0,n.Z)(R,[["render",y],["__scopeId","data-v-6d0e9369"]]);var A=$;const M=[{path:"/",name:"home",component:A}],N=(0,h.p7)({history:(0,h.PO)("/Tone_WebClient/"),routes:M});var Z=N;Symbol();var z=(0,g.MT)({state:{servers:[],players:{},weapons:{}},getters:{getPlayerList:e=>({server:t,weapon:s,minKills:r,minDeaths:a})=>{let l=[];return e.players[""]&&(l=Object.entries(e.players[""]).filter((([,e])=>e.kills>=r||e.deaths>=a)).map((e=>e[0]))),l.length>0&&e.players[(t||"")+(s||"")]?Object.fromEntries(Object.entries(e.players[(t||"")+(s||"")]).filter((([e])=>l.includes(e)))):e.players[(t||"")+(s||"")]},getWeaponList:e=>({server:t,player:s})=>e.weapons[(t||"")+(s||"")]},mutations:{setPlayers(e,t){e.players[(t.filters.server||"")+(t.filters.weapon||"")]=t.data},setWeapons(e,t){e.weapons[(t.filters.server||"")+(t.filters.player||"")]=t.data},setServers(e,t){e.servers=t}},actions:{async fetchPlayers(e,{weapon:t,server:s}){const r={};t?.toString()&&(r.weapon=t),s?.toString()&&(r.server=s);const a=await fetch("https://tone.sleepycat.date/v1/client/players?"+new URLSearchParams(r)),l=await a.json();Object.keys(l).forEach((e=>{l[e].kills=Number(l[e].kills),l[e].deaths=Number(l[e].deaths),l[e].max_kill_distance=Number(l[e].max_kill_distance),l[e].avg_kill_distance=Number(l[e].avg_kill_distance)})),e.commit("setPlayers",{data:l,filters:{weapon:t,server:s}})},async fetchWeapons(e,{player:t,server:s}){const r={};t?.toString()&&(r.player=t),s?.toString()&&(r.server=s);const a=await fetch("https://tone.sleepycat.date/v1/client/weapons?"+new URLSearchParams(r)),l=await a.json();e.commit("setWeapons",{data:l,filters:{player:t,server:s}})},async fetchServers(e){const t=await fetch("https://tone.sleepycat.date/v1/client/servers"),s=await t.json();e.commit("setServers",s)}},modules:{}});(0,r.ri)(c).use(z).use(Z).mount("#app"),z.dispatch("fetchServers",{}),z.dispatch("fetchPlayers",{}),z.dispatch("fetchWeapons",{})}},t={};function s(r){var a=t[r];if(void 0!==a)return a.exports;var l=t[r]={exports:{}};return e[r](l,l.exports,s),l.exports}s.m=e,function(){var e=[];s.O=function(t,r,a,l){if(!r){var i=1/0;for(c=0;c<e.length;c++){r=e[c][0],a=e[c][1],l=e[c][2];for(var n=!0,o=0;o<r.length;o++)(!1&l||i>=l)&&Object.keys(s.O).every((function(e){return s.O[e](r[o])}))?r.splice(o--,1):(n=!1,l<i&&(i=l));if(n){e.splice(c--,1);var d=a();void 0!==d&&(t=d)}}return t}l=l||0;for(var c=e.length;c>0&&e[c-1][2]>l;c--)e[c]=e[c-1];e[c]=[r,a,l]}}(),function(){s.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return s.d(t,{a:t}),t}}(),function(){s.d=function(e,t){for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}}(),function(){s.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()}(),function(){s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){var e={143:0};s.O.j=function(t){return 0===e[t]};var t=function(t,r){var a,l,i=r[0],n=r[1],o=r[2],d=0;if(i.some((function(t){return 0!==e[t]}))){for(a in n)s.o(n,a)&&(s.m[a]=n[a]);if(o)var c=o(s)}for(t&&t(r);d<i.length;d++)l=i[d],s.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return s.O(c)},r=self["webpackChunktoneapi_webclient"]=self["webpackChunktoneapi_webclient"]||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}();var r=s.O(void 0,[998],(function(){return s(9111)}));r=s.O(r)})();
//# sourceMappingURL=app.9c5f7aa2.js.map