updated frontend from typescript to javascript

This commit is contained in:
cnachtigall1991
2021-10-05 00:16:20 +02:00
parent 27edfd0cfe
commit 886f182ff2
41 changed files with 1183 additions and 28 deletions

50
src/utils/index.js Normal file
View File

@@ -0,0 +1,50 @@
import {DateTime} from "luxon/build/es6/luxon";
import router from '@/router'
export const FormatDuration = (d) => {
const hours = Math.floor(d / 3600)
const num = d % 3600
const minutes = Math.floor(num % 3600 / 60)
const seconds = Math.floor(num % 3600 % 60)
if (hours !== 0)
return `${hours}:${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`
else
return `${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`
}
export const FormatDate = (date) => {
const matchDate = DateTime.fromISO(date)
const diff = DateTime.now().diff(matchDate)
if (diff.as('days') > 10)
return matchDate.toLocaleString({weekday: 'short', day: 'numeric', month: 'numeric', year: 'numeric'})
else if (diff.as('days') < 1)
if (diff.as('hours') < 1)
return Math.floor(diff.as('minutes')) + ' minutes ago'
else
return Math.floor(diff.as('hours')) + ' hours ago'
else
return Math.floor(diff.as('days')) + ' days ago'
}
export const GoToMatch = (id) => {
router.push(`/match/${id}`)
}
export const GoToPlayer = (id) => {
router.push(`/player/${id}`)
}
export const GetHLTV_1 = (kills = 0, rounds, deaths = 0, k2 = 0, k3 = 0, k4 = 0, k5 = 0) => {
const k1 = kills - k2 - k3 - k4 - k5
const Weight_KPR = 0.679 // weight kills per round
const Weight_SPR = 0.317 // weight survived rounds per round
const Weight_RMK = 1.277 // weight value calculated from rounds with multiple kills (1k + 4*2k + 9*3k + 16*4k + 25*5k)
const KillRating = kills / rounds / Weight_KPR
const SurvivalRating = (rounds - deaths) / rounds / Weight_SPR
const RoundsWithMultipleKillsRating = (k1 + 4 * k2 + 9 * k3 + 16 * k4 + 25 * k5) / rounds / Weight_RMK
return ((KillRating + 0.7 * SurvivalRating + RoundsWithMultipleKillsRating) / 2.7).toFixed(2)
}