Files
ToneAPI_webclient/dist/js/app.f8f821bc.js
T
2023-04-25 13:23:09 +02:00

2 lines
17 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={3870:function(e,t,r){var s=r(3862),a=r(3396);const i=(0,a.uE)('<div class="navbar-element">TONE API</div><div class="navbar-element github-link"><a href="https://github.com/Legonzaur/Tone_WebClient">Github</a></div><div class="navbar-element github-link"><a href="https://github.com/Legonzaur/ToneAPI_servermod">Northstar Server Mod</a></div><div class="spacer"></div>',4);function l(e,t,r,s,l,o){const n=(0,a.up)("router-link"),h=(0,a.up)("router-view");return(0,a.wg)(),(0,a.iD)(a.HY,null,[(0,a._)("header",null,[(0,a._)("nav",null,[i,(0,a.Wm)(n,{to:"/",class:"navbar-element"},{default:(0,a.w5)((()=>[(0,a.Uk)("Players")])),_:1})])]),(0,a.Wm)(h)],64)}r(7658);var o=r(1020),n=r(5130);function h(e){return Object.fromEntries(Object.entries(e).filter((e=>void 0!==e[1]&&null!==e[1])))}function p(e,t){try{return e=h(e),t=h(t),n.deepStrictEqual(e,t),!0}catch{return!1}}const d=(0,o.Q_)("kill",{state:()=>({servers:[],players:[],weapons:[],maps:[],gamemodes:[],hosts:{}}),getters:{getPlayerList:e=>t=>e.players.find((e=>p(e.filter,t))),getWeaponList:e=>t=>e.weapons.find((e=>p(e.filter,t))),getServerList:e=>t=>e.servers.find((e=>p(e.filter,t)))},actions:{async fetchPlayers(e){e=h(e);const t=await fetch("https://tone.sleepycat.date/v2_test/client/players?"+new URLSearchParams(e)),r=await t.json(),s=this.players.find((t=>p(t.filter,e)));if(!s)return this.players.push({filter:e,data:r});s.data=r},async fetchWeapons(e){e=h(e);const t=await fetch("https://tone.sleepycat.date/v2_test/client/weapons?"+new URLSearchParams(e)),r=await t.json(),s=this.weapons.find((t=>p(t.filter,e)));if(!s)return this.weapons.push({filter:e,data:r});s.data=r},async fetchServers(e){e=h(e);const t=await fetch("https://tone.sleepycat.date/v2_test/client/servers?"+new URLSearchParams(e)),r=await t.json(),s=this.servers.find((t=>p(t.filter,e)));if(!s)return this.servers.push({filter:e,data:r});s.data=r}}});var c=(0,a.aZ)({setup(e,t){const r=d();r.fetchPlayers({}),r.fetchServers({}),r.fetchWeapons({})}}),u=r(89);const g=(0,u.Z)(c,[["render",l]]);var y=g,f=r(2483);const m={id:"filters"},v={id:"playerView"};function b(e,t,r,s,i,l){const o=(0,a.up)("VueMultiselect"),n=(0,a.up)("PlayerList"),h=(0,a.up)("PlayerChart"),p=(0,a.up)("WeaponChart");return(0,a.wg)(),(0,a.iD)(a.HY,null,[(0,a._)("div",m,[(0,a.Wm)(o,{selectLabel:"",deselectLabel:"remove",placeholder:"Select server",modelValue:e.model.server,"onUpdate:modelValue":t[0]||(t[0]=t=>e.model.server=t),options:e.groupedServers,"group-values":"servers",group_label:"id","group-select":!1,"allow-empty":!0,multiple:!1,"custom-label":e=>e.name,"track-by":"name",label:"name"},null,8,["modelValue","options","custom-label"]),(0,a.Wm)(o,{selectLabel:"",deselectLabel:"remove",placeholder:"Select weapon",modelValue:e.model.weapon,"onUpdate:modelValue":t[1]||(t[1]=t=>e.model.weapon=t),options:e.sortedWeaponList,"allow-empty":!0},null,8,["modelValue","options"]),(0,a.Wm)(o,{selectLabel:"",deselectLabel:"remove",placeholder:"Search player",modelValue:e.playerHighlighted,"onUpdate:modelValue":t[2]||(t[2]=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",v,[(0,a.Wm)(n,{filters:e.filters,onHighlightPlayer:t[3]||(t[3]=t=>e.playerHighlighted=t),playerHighlighted:e.playerHighlighted},null,8,["filters","playerHighlighted"]),(0,a.Wm)(h,{filters:e.filters,onHighlightPlayer:t[4]||(t[4]=t=>e.playerHighlighted=t),playerHighlighted:e.playerHighlighted},null,8,["filters","playerHighlighted"]),(0,a.Wm)(p,{filters:{player:e.playerHighlighted,...e.filters},playerHighlighted:e.playerHighlighted},null,8,["filters","playerHighlighted"])])],64)}var w=r(7139);const k=e=>((0,a.dD)("data-v-33cdd346"),e=e(),(0,a.Cn)(),e),L={class:"playerHeaders"},P=k((()=>(0,a._)("span",null,null,-1))),_=["onClick"];function H(e,t,r,s,i,l){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",L,[P,(0,a._)("span",{onClick:t[0]||(t[0]=t=>e.sortPlayerList("username")),class:(0,w.C_)("username"==e.sortingData.argument?"selected":"")},"Username",2),(0,a._)("span",{onClick:t[1]||(t[1]=t=>e.sortPlayerList("kills")),class:(0,w.C_)("kills"==e.sortingData.argument?"selected":"")},"K",2),(0,a._)("span",{onClick:t[2]||(t[2]=t=>e.sortPlayerList("deaths")),class:(0,w.C_)("deaths"==e.sortingData.argument?"selected":"")},"D",2),(0,a._)("span",{onClick:t[3]||(t[3]=t=>e.sortPlayerList("k/d")),class:(0,w.C_)("k/d"==e.sortingData.argument?"selected":"")},"K/D",2),(0,a._)("span",{onClick:t[4]||(t[4]=t=>e.sortPlayerList("max_distance")),class:(0,w.C_)("max_distance"==e.sortingData.argument?"selected":"")},"max distance",2),(0,a._)("span",{onClick:t[5]||(t[5]=t=>e.sortPlayerList("avg_distance")),class:(0,w.C_)("avg_distance"==e.sortingData.argument?"selected":"")},"average distance",2)]),((0,a.wg)(!0),(0,a.iD)(a.HY,null,(0,a.Ko)(e.playerIdList,((t,r)=>((0,a.wg)(),(0,a.iD)("div",{class:(0,w.C_)("playerRow "+(t===e.$props.playerHighlighted?"selected":"")),key:t,onClick:r=>e.$emit("highlightPlayer",t),ref_for:!0,ref:"player:"+t},[(0,a._)("div",null,[(0,a._)("span",null,(0,w.zw)(r+1),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,w.zw)(e.players[t].username),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,w.zw)(e.players[t].kills),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,w.zw)(e.players[t].deaths),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,w.zw)(Math.round(e.players[t].kills/Math.max(1,e.players[t].deaths)*100)/100),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,w.zw)(e.players[t].max_distance),1)]),(0,a._)("div",null,[(0,a._)("span",null,(0,w.zw)(Math.round(100*(e.players[t].total_distance/e.players[t].kills||0))/100),1)])],10,_)))),128))],32)}var I=(0,a.aZ)({props:{filters:{type:Object,default:()=>({})},playerHighlighted:String},emits:["highlightPlayer"],data(){return{sortingData:{direction:-1,argument:"kills"},playerIdList:[],store:d()}},computed:{players(){const{player:e,...t}=this.filters;return this.store.getPlayerList(t)?.data||{}}},watch:{players:{handler(e){e&&(this.playerIdList=[],this.sortingData.direction*=-1,this.playerIdList=Object.keys(e),this.sortPlayerList(this.sortingData.argument),this.playerIdList=this.playerIdList.slice(0,500))},immediate:!0},playerHighlighted(e){const t=this.$refs["player:"+e];t&&t[0]&&t[0].scrollIntoView({behavior:"smooth",block:"center"})}},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,r)=>{if(!this.players)return 0;let s,a;return"k/d"===e?(s=this.players[t].kills/Math.max(1,this.players[t].deaths),a=this.players[r].kills/Math.max(1,this.players[r].deaths)):"avg_distance"===e?(s=this.players[t].total_distance/this.players[t].kills||0,a=this.players[r].total_distance/this.players[r].kills||0):(s=this.players[t][e],a=this.players[r][e]),void 0===s||void 0===a?0:s<a?-1*this.sortingData.direction:s>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.$props.playerHighlighted)return;if(!Object.keys(t).includes(e.key))return;e.preventDefault();const r=this.playerIdList.indexOf(this.$props.playerHighlighted);let s=r+t[e.key];s>=this.playerIdList.length&&(s=this.playerIdList.length-1),s<0&&(s=0),this.$emit("highlightPlayer",this.playerIdList[s])}}});const C=(0,u.Z)(I,[["render",H],["__scopeId","data-v-33cdd346"]]);var x=C;const O={class:"playerChart",ref:"container"};function $(e,t,r,s,i,l){const o=(0,a.up)("Scatter");return(0,a.wg)(),(0,a.iD)("div",O,[(0,a.Wm)(o,{data:e.chart,options:e.chartOptions},null,8,["data","options"])],512)}var D=r(3254),W=r(9152),V=r(1131),j=r(5866);D.kL.register(D.f$,D.od,D.jn,D.u,D.De,W.Z,V.Z);var S=(0,a.aZ)({name:"PlayerChart",props:{filters:Object,playerHighlighted:String},data:()=>({store:d(),refreshColors:0}),emits:["highlightPlayer"],components:{Scatter:j.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(){return{datasets:[{label:"Players",labels:this.playerIdList||[],borderColor:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?this.colors.orange:this.colors.cyan,backgroundColor:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?this.colors.orange:this.colors.cyan,pointRadius:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?20:1,pointStyle:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?"crossRot":"circle",hoverRadius:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?30:4,data:this.playerIdList.map((e=>({y:this.players[e].kills,x:this.players[e].deaths})))}]}},chartOptions(){this.$props.playerHighlighted;let e=0,t=0;if(this.players){const r=Math.max(...Object.values(this.players).map((e=>e.deaths))),s=Math.max(...Object.values(this.players).map((e=>e.kills)));s>r?(e=r,t=r/s*s):(t=s,e=s/r*r)}return{responsive:!0,maintainAspectRatio:!1,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:{annotations:{line:{type:"line",yMin:0,xMin:0,yMax:t,xMax:e,borderWidth:2,borderColor:this.colors.orange,borderDash:[1,5]}}},legend:{display:!1},datalabels:{formatter:(e,t)=>this.players[this.playerIdList[t.dataIndex]].username,backgroundColor:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.dataIndex]?this.colors.orange:null,borderColor:this.colors.fg,borderWidth:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.dataIndex]?1:0,borderRadius:5,display:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.dataIndex]?"true":"auto",align:-45,anchor:"end",clamp:!0,color:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.dataIndex]?this.colors.bg: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")}}},players(){const e=this.store.getPlayerList(this.filters||{})?.data;if(!e)return{};const t=Object.entries(e).sort(((e,t)=>e[1].kills<t[1].kills?1:e[1].kills>t[1].kills?-1:0)).slice(0,200);return Object.fromEntries(t)},playerIdList(){return Object.keys(this.players)}}});const M=(0,u.Z)(S,[["render",$],["__scopeId","data-v-a55781c4"]]);var Z=M;const R={class:"weaponChart",ref:"container"};function U(e,t,r,s,i,l){const o=(0,a.up)("Doughnut");return(0,a.wg)(),(0,a.iD)("div",R,[(0,a.Wm)(o,{data:e.chart,options:e.chartOptions},null,8,["data","options"])],512)}D.kL.register(D.qi,D.u,D.De,V.Z);var z=(0,a.aZ)({name:"PlayerChart",props:{filters:Object,playerHighlighted:String},emits:["highlightPlayer"],components:{Doughnut:j.$I},mounted(){this.refreshColors++},data:()=>({store:d(),refreshColors:0}),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.yellow=t.getPropertyValue("--yellow"),e.green=t.getPropertyValue("--green"),e.purple=t.getPropertyValue("--purple"),e.red=t.getPropertyValue("--red"),e.pink=t.getPropertyValue("--pink"),e.currentLine=t.getPropertyValue("--current-line")}else e.fg="#ffffff";return e},chart(){const e=["cyan","green","orange","pink","purple","red","yellow"],t={datasets:[{label:"Weapons",labels:this.sortedWeaponList||[],borderColor:()=>this.colors.fg,backgroundColor:t=>this.colors[e[3*t.dataIndex%e.length]],data:[]}]};return this.sortedWeaponList?(t.datasets[0].data=this.sortedWeaponList.map((e=>this.weapons?this.weapons[e].kills:0)),t):t},chartOptions(){this.$props.playerHighlighted;const e={responsive:!0,maintainAspectRatio:!0,animation:{duration:500},layout:{autoPadding:!1},plugins:{datalabels:{formatter:(e,t)=>this.sortedWeaponList[t.dataIndex],backgroundColor:e=>e.dataset.backgroundColor(e),borderColor:this.colors.fg,borderRadius:25,borderWidth:2,color:this.colors.bg,display:e=>e.dataIndex===e.dataset.labels.length-1||"auto",padding:6},tooltip:{callbacks:{label:e=>{let t;return t=this.sortedWeaponList?this.sortedWeaponList[e.dataIndex]:e.dataset.labels[e.dataIndex],t+=" ("+this.weapons[t].kills+" kills)",t}}}}};return e},weapons(){const{weapon:e,...t}=this.filters||{},r=this.store.getWeaponList(t)?.data;return r||(this.store.fetchWeapons(t),{})},sortedWeaponList(){if(!this.weapons)return[];const e=Object.keys(this.weapons);return e.sort(((e,t)=>Number(this.weapons[e].kills)<Number(this.weapons[t].kills)?-1:Number(this.weapons[e].kills)>Number(this.weapons[t].kills)?1:0)),e}}});const A=(0,u.Z)(z,[["render",U],["__scopeId","data-v-673fd0b6"]]);var N=A,E=r(6368),T=(0,a.aZ)({name:"PlayerView",components:{VueMultiselect:E.ZP,PlayerList:x,PlayerChart:Z,WeaponChart:N},data(){return{model:{server:void 0,weapon:void 0},filters:{},store:d(),playerHighlighted:void 0}},computed:{servers(){const{server:e,player:t,...r}=this.filters,s=this.store.getServerList(r)?.data;return s||(this.store.fetchServers(r),{})},groupedServers(){const e=[];return Object.entries(this.servers).forEach((t=>{e.find((e=>e.id===t[1].host+"sfdsdfsd"))||e.push({id:t[1].host+"sfdsdfsd",servers:[]}),e.find((e=>e.id===t[1].host+"sfdsdfsd"))?.servers.push({name:t[0],...t[1]})})),e},weapons(){const{weapon:e,player:t,...r}=this.filters,s=this.store.getWeaponList(r)?.data;return s||(this.store.fetchWeapons(r),{})},players(){const{player:e,...t}=this.filters,r=this.store.getPlayerList(t)?.data;return r||(this.store.fetchPlayers(t),{})},sortedWeaponList(){if(!this.weapons)return[];const e=Object.keys(this.weapons);return e.sort()},sortedServerList(){if(!this.servers)return[];const e=Object.keys(this.servers);return e.sort()},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:{model:{handler(e){this.filters.server=e.server?.name,this.filters.weapon=e.weapon},deep:!0}}});const K=(0,u.Z)(T,[["render",b],["__scopeId","data-v-8bebdda4"]]);var Y=K;const q=[{path:"/",name:"home",component:Y}],B=(0,f.p7)({history:(0,f.PO)("/ToneAPI_webclient/"),routes:q});var F=B;const G=(0,o.WB)();(0,s.ri)(y).use(G).use(F).mount("#app")}},t={};function r(s){var a=t[s];if(void 0!==a)return a.exports;var i=t[s]={exports:{}};return e[s](i,i.exports,r),i.exports}r.m=e,function(){var e=[];r.O=function(t,s,a,i){if(!s){var l=1/0;for(p=0;p<e.length;p++){s=e[p][0],a=e[p][1],i=e[p][2];for(var o=!0,n=0;n<s.length;n++)(!1&i||l>=i)&&Object.keys(r.O).every((function(e){return r.O[e](s[n])}))?s.splice(n--,1):(o=!1,i<l&&(l=i));if(o){e.splice(p--,1);var h=a();void 0!==h&&(t=h)}}return t}i=i||0;for(var p=e.length;p>0&&e[p-1][2]>i;p--)e[p]=e[p-1];e[p]=[s,a,i]}}(),function(){r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,{a:t}),t}}(),function(){r.d=function(e,t){for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})}}(),function(){r.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()}(),function(){r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){var e={143:0};r.O.j=function(t){return 0===e[t]};var t=function(t,s){var a,i,l=s[0],o=s[1],n=s[2],h=0;if(l.some((function(t){return 0!==e[t]}))){for(a in o)r.o(o,a)&&(r.m[a]=o[a]);if(n)var p=n(r)}for(t&&t(s);h<l.length;h++)i=l[h],r.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return r.O(p)},s=self["webpackChunktoneapi_webclient"]=self["webpackChunktoneapi_webclient"]||[];s.forEach(t.bind(null,0)),s.push=t.bind(null,s.push.bind(s))}();var s=r.O(void 0,[998],(function(){return r(3870)}));s=r.O(s)})();
//# sourceMappingURL=app.f8f821bc.js.map